Commits

Virgil Dupras committed 60cbd80

Removed usage of TestCase in all tests.

  • Participants
  • Parent commits e0aa584

Comments (0)

Files changed (14)

 0de9e6033a1fb339a293923241ebc3f28ec5853f cocoalib
-d2cd0d380e01d2c68814e11eee1baa6204d757d7 hscommon
+428ae037043e6bd57f317605697c15be0a2692f3 hscommon
 9fa20059180e555e009c8fe28a33b28aa4a66473 qtlib
 # http://www.hardcoded.net/licenses/bsd_license
 
 from hscommon.path import Path
-from hscommon.testcase import TestCase
+from hscommon.testutil import eq_
 
 from .app_cocoa import MusicGuru
 from .sqlfs.music import Root, VOLTYPE_CDROM
 
-class TCApp_GetLocationData(TestCase):
-    def test_values(self):
-        root = Root(threaded=False)
-        root.buffer_path = Path('/does/not/exist')
-        loc = root.new_directory('foo')
-        loc.vol_type = VOLTYPE_CDROM
-        # Let's fake its stats
-        loc._Stats__stats = {'size': int(3.5 * 1024 * 1024 * 1024), 'filecount': 42}
-        app = MusicGuru()
-        expected = ['foo', 42, '3.50', True, False, str(Path('/does/not/exist/foo'))]
-        result = app.GetLocationData(loc)
-        self.assertEqual(expected, result)
-        # The path supplied must be a unicode string, it is going through the pyobjc bridge
-        self.assert_(isinstance(result[5], str))
+def test_values():
+    root = Root(threaded=False)
+    root.buffer_path = Path('/does/not/exist')
+    loc = root.new_directory('foo')
+    loc.vol_type = VOLTYPE_CDROM
+    # Let's fake its stats
+    loc._Stats__stats = {'size': int(3.5 * 1024 * 1024 * 1024), 'filecount': 42}
+    app = MusicGuru()
+    expected = ['foo', 42, '3.50', True, False, str(Path('/does/not/exist/foo'))]
+    result = app.GetLocationData(loc)
+    eq_(expected, result)
+    # The path supplied must be a unicode string, it is going through the pyobjc bridge
+    assert isinstance(result[5], str)
     

core/design_test.py

 from hscommon.testutil import eq_
 
 from . import fs_utils, manualfs, design
-from .sqlfs.music import Root, VOLTYPE_CDROM, VOLTYPE_FIXED
-from .testcase import TestCase
+from .sqlfs.music import Root
+from .testutil import testdata
 
-class TCBoard(TestCase):
-    def setUp(self):
-        self.root = Root(self.filepath('sql','small.db'), threaded=False)
+class TestBoard:
+    def setup_method(self, method):
+        self.root = Root(testdata.filepath('sql','small.db'), threaded=False)
         self.board = design.Board()
         self.board.AddLocation(self.root[0])
 
     #---Locations
     def test_location_is_added(self):
-        self.assert_(self.root[0] in self.board.locations)
-        self.assertEqual(7,len(self.board))
-        self.assertEqual('08 Peephole.wma',self.board[0].name)
+        assert self.root[0] in self.board.locations
+        eq_(7,len(self.board))
+        eq_('08 Peephole.wma',self.board[0].name)
 
     def test_location_is_read_only(self):
         self.board.locations.remove(self.root[0])
-        self.assert_(self.root[0] in self.board.locations)
+        assert self.root[0] in self.board.locations
 
     def test_remove_location(self):
         self.board.RemoveLocation(self.root[0])
-        self.assert_(self.root[0] not in self.board.locations)
-        self.assertEqual(0,len(self.board))
+        assert self.root[0] not in self.board.locations
+        eq_(0,len(self.board))
 
     def test_remove_location_not_in_board(self):
         self.board.RemoveLocation(self.root)
-        self.assertEqual(7,len(self.board))
-        self.assertEqual(1,len(self.board.locations))
+        eq_(7,len(self.board))
+        eq_(1,len(self.board.locations))
 
     def test_toggle_location(self):
         self.board.ToggleLocation(self.root[0])
-        self.assert_(self.root[0] not in self.board.locations)
-        self.assertEqual(0,len(self.board))
+        assert self.root[0] not in self.board.locations
+        eq_(0,len(self.board))
         self.board.ToggleLocation(self.root[0])
-        self.assert_(self.root[0] in self.board.locations)
-        self.assertEqual(7,len(self.board))
+        assert self.root[0] in self.board.locations
+        eq_(7,len(self.board))
 
     def test_empty_dir_after_remove_location(self):
         new = self.board.new_directory('foobar')
         self.board.RemoveLocation(self.root[0])
-        self.assert_(self.root[0] not in self.board.locations)
-        self.assertEqual(0,len(self.board))
+        assert self.root[0] not in self.board.locations
+        eq_(0,len(self.board))
 
     def test_also_remove_from_ignore_box(self):
         self.board[0].move(self.board.ignore_box)
         self.board.RemoveLocation(self.root[0])
-        self.assertEqual(0,len(self.board.ignore_box))
+        eq_(0,len(self.board.ignore_box))
 
     #---Node Manipulation
     def test_is_auto_merge(self):
         f1,f2 = self.board[:2]
         f1.name = 'foobar'
         f2.name = 'FoObAr'
-        self.assertEqual('[000] FoObAr',f2.name)    
+        eq_('[000] FoObAr',f2.name)    
 
     #---High level functions
     def test_mass_rename(self):
         self.board.media_capacity = 700
         self.board.MassRename("%year% - %artist% - %title%",fs_utils.WS_SPACES_TO_UNDERSCORES)
-        self.assertEqual('2001 - Manu_Chao - La_Primavera._Bleh.mp3',self.board[0].name)
-        self.assertEqual(1,len(self.board.conflicts))
-        self.assertEqual(False,self.board.splitted)
+        eq_('2001 - Manu_Chao - La_Primavera._Bleh.mp3',self.board[0].name)
+        eq_(1,len(self.board.conflicts))
+        eq_(False,self.board.splitted)
         not_renamed = self.board['(not renamed)']
-        self.assertEqual(1,len(not_renamed))
+        eq_(1,len(not_renamed))
 
     def test_that_mass_rename_priorizes(self):
-        root = Root(self.filepath('sql','small.db'), threaded=False)
+        root = Root(testdata.filepath('sql','small.db'), threaded=False)
         self.board.AddLocation(root[0])
         self.board.MassRename("foobar/%year% - %artist% - %title%",fs_utils.WS_SPACES_TO_UNDERSCORES)
-        self.assertEqual(8,len(self.board.allconflicts))
-        self.assertEqual(1,len([s for s in self.board.allconflicts if s.original.parent_volume is self.board.locations[0]]))
+        eq_(8,len(self.board.allconflicts))
+        eq_(1,len([s for s in self.board.allconflicts if s.original.parent_volume is self.board.locations[0]]))
         
     def test_mass_rename_case_insensitive(self):
         self.board[0].artist = 'foobar'
         self.board[1].artist = 'FOOBAR'
         self.board.MassRename("parent_dir/%artist%/%title%",fs_utils.WS_SPACES_TO_UNDERSCORES)
-        self.assertEqual(7,len(self.board.allfiles))
+        eq_(7,len(self.board.allfiles))
 
     def test_empty(self):
-        root = Root(self.filepath('sql','small.db'), threaded=False)
+        root = Root(testdata.filepath('sql','small.db'), threaded=False)
         self.board.AddLocation(root[0])
         self.board.media_capacity = 8500
         self.board[0].move(self.board.ignore_box)
-        self.assertEqual(13,len(self.board))
-        self.assertEqual(1,len(self.board.ignore_box))
+        eq_(13,len(self.board))
+        eq_(1,len(self.board.ignore_box))
         self.board.Empty()
-        self.assertEqual(0,len(self.board))
-        self.assertEqual(0,len(self.board.locations))
-        self.assertEqual(0,len(self.board.ignore_box))
-        self.assertEqual(False,self.board.splitted)
+        eq_(0,len(self.board))
+        eq_(0,len(self.board.locations))
+        eq_(0,len(self.board.ignore_box))
+        eq_(False,self.board.splitted)
 
     def test_priorize_conflicts(self):
-        root = Root(self.filepath('sql','small.db'), threaded=False)
+        root = Root(testdata.filepath('sql','small.db'), threaded=False)
         self.board.AddLocation(root[0])
         f1 = self.board['08 Peephole.wma']
         f2 = self.board['[000] 08 Peephole.wma']
         f2.name = '08 Peephole.wma'
         f1.name = '[000] 08 Peephole.wma'
         self.board.PriorizeConflicts()
-        self.assertEqual('08 Peephole.wma',f1.name)
-        self.assertEqual('[000] 08 Peephole.wma',f2.name)
+        eq_('08 Peephole.wma',f1.name)
+        eq_('[000] 08 Peephole.wma',f2.name)
 
     def test_split(self):
         self.board.Split('CD %sequence%',1,0)
-        self.assertEqual(7,len(self.board.dirs))
-        self.assertEqual('CD 1',self.board[0].name)
-        self.assert_(self.board.splitted)
+        eq_(7,len(self.board.dirs))
+        eq_('CD 1',self.board[0].name)
+        assert self.board.splitted
         self.board.Unsplit()
 
     def test_unsplit(self):
         self.board.Split('CD %sequence%', 0xffffffff, 0)
-        self.assert_(self.board.splitted)
+        assert self.board.splitted
         self.board.Unsplit()
-        self.assert_(not self.board.splitted)
-        self.assertEqual('08 Peephole.wma',self.board[0].name)
-        self.assertEqual(7, len(self.board))
+        assert not self.board.splitted
+        eq_('08 Peephole.wma',self.board[0].name)
+        eq_(7, len(self.board))
     
     def test_get_stat_line(self):
-        self.assertEqual("7 songs, 27.3 minutes, 34.73 MB",self.board.stats_line)
-        root = Root(self.filepath('sql','small.db'), threaded=False)
+        eq_("7 songs, 27.3 minutes, 34.73 MB",self.board.stats_line)
+        root = Root(testdata.filepath('sql','small.db'), threaded=False)
         self.board.AddLocation(root[0])
         self.board.MassRename("foobar/%year% - %artist% - %title%",fs_utils.WS_SPACES_TO_UNDERSCORES)
-        self.assertEqual("14 songs (8 conflicts), 54.7 minutes, 69.45 MB",self.board.stats_line)
+        eq_("14 songs (8 conflicts), 54.7 minutes, 69.45 MB",self.board.stats_line)
         
     def test_stats(self):
         self.board.MassRename("%artist%\%title%",fs_utils.WS_SPACES_TO_UNDERSCORES)
-        self.assertEqual(len(self.board.get_stat('artist',[])),3)
-        self.assertEqual(len(self.board[1].get_stat('artist',[])),1)
-        self.assertEqual(len(self.board[0].get_stat('artist',[])),1)
+        eq_(len(self.board.get_stat('artist',[])),3)
+        eq_(len(self.board[1].get_stat('artist',[])),1)
+        eq_(len(self.board[0].get_stat('artist',[])),1)
 
     #---Conflicts
     def test_move_conflicts(self):
         self.board.MassRename("%year% - %artist% - %title%",fs_utils.WS_SPACES_TO_UNDERSCORES)
-        self.assertEqual(7,len(self.board))
-        self.assertEqual(1,len(self.board.conflicts))
-        self.assertEqual(1,self.board.MoveConflicts())
-        self.assertEqual(6,len(self.board))
-        self.assertEqual(1,len(self.board.ignore_box.allfiles))
-        self.assertEqual(0,len(self.board.allconflicts))
+        eq_(7,len(self.board))
+        eq_(1,len(self.board.conflicts))
+        eq_(1,self.board.MoveConflicts())
+        eq_(6,len(self.board))
+        eq_(1,len(self.board.ignore_box.allfiles))
+        eq_(0,len(self.board.allconflicts))
 
     def test_move_conflicts_to_original(self):
         f = self.board[0]
         f.name = '[000] foobar'
-        self.assertEqual(7,len(self.board))
-        self.assertEqual(1,len(self.board.conflicts))
-        self.assertEqual(0,self.board.MoveConflicts())
-        self.assertEqual(7,len(self.board))
-        self.assertEqual(0,len(self.board.ignore_box.allfiles))
-        self.assertEqual(0,len(self.board.allconflicts))
-        self.assertEqual('foobar',f.name)
+        eq_(7,len(self.board))
+        eq_(1,len(self.board.conflicts))
+        eq_(0,self.board.MoveConflicts())
+        eq_(7,len(self.board))
+        eq_(0,len(self.board.ignore_box.allfiles))
+        eq_(0,len(self.board.allconflicts))
+        eq_('foobar',f.name)
 
     def test_move_conflicts_and_original(self):
         self.board.MassRename("%year% - %artist% - %title%",fs_utils.WS_SPACES_TO_UNDERSCORES)
-        self.assertEqual(7,len(self.board))
-        self.assertEqual(1,len(self.board.allconflicts))
-        self.assertEqual(2,self.board.MoveConflicts(True))
-        self.assertEqual(5,len(self.board))
-        self.assertEqual(2,len(self.board.ignore_box.allfiles))
-        self.assertEqual(0,len(self.board.allconflicts))
+        eq_(7,len(self.board))
+        eq_(1,len(self.board.allconflicts))
+        eq_(2,self.board.MoveConflicts(True))
+        eq_(5,len(self.board))
+        eq_(2,len(self.board.ignore_box.allfiles))
+        eq_(0,len(self.board.allconflicts))
 
-class TCMassRenamePanel(TestCase):
-    def setUp(self):
-        root = Root(self.filepath('sql','small.db'), threaded=False)
+class TestMassRenamePanel:
+    def setup_method(self, method):
+        root = Root(testdata.filepath('sql','small.db'), threaded=False)
         self.panel = design.MassRenamePanel(root)
 
     def test_default(self):
-        self.assertEqual(0,self.panel.model_index)
-        self.assertEqual(0,self.panel.whitespace_index)
-        self.assertEqual("%artist%/%album%/%track% - %artist% - %title%",self.panel.model)
-        self.assertEqual(fs_utils.WS_DONT_TOUCH,self.panel.whitespace)
+        eq_(0,self.panel.model_index)
+        eq_(0,self.panel.whitespace_index)
+        eq_("%artist%/%album%/%track% - %artist% - %title%",self.panel.model)
+        eq_(fs_utils.WS_DONT_TOUCH,self.panel.whitespace)
 
     def test_change(self):
         self.panel.model_index = 3
-        self.assertEqual(3,self.panel.model_index)
-        self.assertEqual("%artist%/%album% - %track% - %title%",self.panel.model)
+        eq_(3,self.panel.model_index)
+        eq_("%artist%/%album% - %track% - %title%",self.panel.model)
         self.panel.whitespace_index = 2
-        self.assertEqual(2,self.panel.whitespace_index)
-        self.assertEqual(fs_utils.WS_UNDERSCORES_TO_SPACES,self.panel.whitespace)
+        eq_(2,self.panel.whitespace_index)
+        eq_(fs_utils.WS_UNDERSCORES_TO_SPACES,self.panel.whitespace)
         self.panel.model_index = 4
-        self.assertEqual("%group:artist:emp:upper%/%artist%/%track% - %artist% - %title%",self.panel.model)
+        eq_("%group:artist:emp:upper%/%artist%/%track% - %artist% - %title%",self.panel.model)
         self.panel.custom_model = 'foobar'
         self.panel.model_index = 234
-        self.assertEqual("foobar",self.panel.model)
+        eq_("foobar",self.panel.model)
 
     def test_example(self):
         def mock_choice(among):
 
         oldchoice = random.choice
         random.choice = mock_choice
-        self.assertEqual(op.join('mftest','08 Peephole.wma'),self.panel.example_before)
-        self.assertEqual(op.join('Strings of SOD','String Tribute to System of a Down','08 - Strings of SOD - Peephole.wma'),self.panel.example_after)
+        eq_(op.join('mftest','08 Peephole.wma'),self.panel.example_before)
+        eq_(op.join('Strings of SOD','String Tribute to System of a Down','08 - Strings of SOD - Peephole.wma'),self.panel.example_after)
         self.panel.refdir.clear()
         self.panel.ChangeExample()
-        self.assertEqual('',self.panel.example_before)
-        self.assertEqual('',self.panel.example_after)
+        eq_('',self.panel.example_before)
+        eq_('',self.panel.example_after)
         random.choice = oldchoice
 
-class TCSplittingPanel(TestCase):
-    def setUp(self):
+class TestSplittingPanel:
+    def setup_method(self, method):
         self.panel = design.SplittingPanel(manualfs.Directory(None,''))
 
     def test_default(self):
-        self.assertEqual(0,self.panel.model_index)
-        self.assertEqual(0,self.panel.capacity_index)
-        self.assertEqual("CD %sequence%",self.panel.model)
-        self.assertEqual(700 * 1024 * 1024,self.panel.capacity)
+        eq_(0,self.panel.model_index)
+        eq_(0,self.panel.capacity_index)
+        eq_("CD %sequence%",self.panel.model)
+        eq_(700 * 1024 * 1024,self.panel.capacity)
 
     def test_change(self):
         self.panel.model_index = 2
-        self.assertEqual(2,self.panel.model_index)
-        self.assertEqual("CD %item:first:1% - %item:last:1%",self.panel.model)
+        eq_(2,self.panel.model_index)
+        eq_("CD %item:first:1% - %item:last:1%",self.panel.model)
         self.panel.capacity_index = 2
-        self.assertEqual(2,self.panel.capacity_index)
-        self.assertEqual(8.5 * 1000 * 1000 * 1000,self.panel.capacity)
+        eq_(2,self.panel.capacity_index)
+        eq_(8.5 * 1000 * 1000 * 1000,self.panel.capacity)
         self.panel.model_index = 4
-        self.assertEqual("CD %item:first:3% - %item:last:3%",self.panel.model)
+        eq_("CD %item:first:3% - %item:last:3%",self.panel.model)
         self.panel.custom_model = 'foobar'
         self.panel.model_index = 234
-        self.assertEqual("foobar",self.panel.model)
+        eq_("foobar",self.panel.model)
 
     def test_grouping(self):
         d1 = self.panel.refdir.new_directory('foo')
         d2 = d1.new_directory('bar')
-        self.assertEqual('(No grouping)',self.panel.example)
+        eq_('(No grouping)',self.panel.example)
         self.panel.grouping_level = 1
-        self.assertEqual(os.sep + 'foo',self.panel.example)
+        eq_(os.sep + 'foo',self.panel.example)
         self.panel.grouping_level = 2
-        self.assertEqual(op.join(os.sep + 'foo','bar'),self.panel.example)
+        eq_(op.join(os.sep + 'foo','bar'),self.panel.example)
         self.panel.grouping_level = 3
-        self.assertEqual('(No folder at this level)',self.panel.example)
+        eq_('(No folder at this level)',self.panel.example)
         
     def test_capacities(self):
         #The CD are really 700 mb, but the gb advertised on dvd cases are 4.7 * 1000 * 1000 * 1000 and 8.5 * 1000 * 1000 * 1000
-        self.assertEqual(700 * 1024 * 1024,self.panel.capacity)
+        eq_(700 * 1024 * 1024,self.panel.capacity)
         self.panel.capacity_index = 1
-        self.assertEqual(4.7 * 1000 * 1000 * 1000,self.panel.capacity)
+        eq_(4.7 * 1000 * 1000 * 1000,self.panel.capacity)
         self.panel.capacity_index = 2
-        self.assertEqual(8.5 * 1000 * 1000 * 1000,self.panel.capacity)
+        eq_(8.5 * 1000 * 1000 * 1000,self.panel.capacity)
         self.panel.capacity_index = 3
         self.panel.custom_capacity = 42
-        self.assertEqual(self.panel.capacity, 42*1024*1024)
+        eq_(self.panel.capacity, 42*1024*1024)
         self.panel.capacity_index = 0
-        self.assertEqual(700 * 1024 * 1024,self.panel.capacity)
+        eq_(700 * 1024 * 1024,self.panel.capacity)

core/fs_utils_test.py

 # which should be included with this package. The terms are also available at 
 # http://www.hardcoded.net/licenses/bsd_license
 
+import os
 import os.path as op
-import os
 from io import StringIO
 import sys
 import weakref
 from jobprogress.job import Job
 
 from . import manualfs
-from .testcase import TestCase
 from .fs_utils import *
-from .sqlfs.music import Root, VOLTYPE_CDROM, VOLTYPE_FIXED
+from .sqlfs.music import Root, VOLTYPE_CDROM
 
 class TestDir(manualfs.Directory):
     def AddDir(self,dirname):
     def AddFile(self,filename):
         return self._create_sub_file(filename)
 
-class SmartMove(TestCase):
+class TestSmartMove:
     def test_simple(self):
         merge_from = TestDir(None,'merge_from')
         merge_into = TestDir(None,'merge_into')
         assert subfile in subdir
     
 
-class TCGetNewName(TestCase):
+class TestGetNewName:
     #The GetNewName functionnality has been moved to the RestructureView.
     #Moving all these tests individually would be too long. What I'll do
     #is that I'll create an interface here that will call restructuredirectory
 
     def test_simple(self):
         #That all values that can be supplied as an argument in the model.
-        self.assertEqual('bar.mp3',self.MockGetNewName(self.Gen({}),'%oldfilename%'))
-        self.assertEqual('foo_artist.mp3',self.MockGetNewName(self.Gen({'artist':'foo_artist'}),'%artist%'))
-        self.assertEqual('foo_album.mp3',self.MockGetNewName(self.Gen({'album':'foo_album'}),'%album%'))
-        self.assertEqual('2005.mp3',self.MockGetNewName(self.Gen({'year':2005}),'%year%'))
-        self.assertEqual('foo_genre.mp3',self.MockGetNewName(self.Gen({'genre':'foo_genre'}),'%genre%'))
-        self.assertEqual('09.mp3',self.MockGetNewName(self.Gen({'track':9}),'%track%'))
-        self.assertEqual('foo_title.mp3',self.MockGetNewName(self.Gen({'title':'foo_title'}),'%title%'))
-        self.assertEqual('foo.mp3',self.MockGetNewName(self.Gen({}),'%oldpath%'))
+        eq_('bar.mp3',self.MockGetNewName(self.Gen({}),'%oldfilename%'))
+        eq_('foo_artist.mp3',self.MockGetNewName(self.Gen({'artist':'foo_artist'}),'%artist%'))
+        eq_('foo_album.mp3',self.MockGetNewName(self.Gen({'album':'foo_album'}),'%album%'))
+        eq_('2005.mp3',self.MockGetNewName(self.Gen({'year':2005}),'%year%'))
+        eq_('foo_genre.mp3',self.MockGetNewName(self.Gen({'genre':'foo_genre'}),'%genre%'))
+        eq_('09.mp3',self.MockGetNewName(self.Gen({'track':9}),'%track%'))
+        eq_('foo_title.mp3',self.MockGetNewName(self.Gen({'title':'foo_title'}),'%title%'))
+        eq_('foo.mp3',self.MockGetNewName(self.Gen({}),'%oldpath%'))
 
     def test_combined(self):
         #Try a couple of combinations.
             }
         model = '%artist%/%album%/%track% - %artist% - %title%'
         expected = op.join('foo_artist','foo_album','09 - foo_artist - foo_title.mp3')
-        self.assertEqual(expected,self.MockGetNewName(self.Gen(attrs),model))
+        eq_(expected,self.MockGetNewName(self.Gen(attrs),model))
         model = '%artist%/%album%/%track% - %title%'
         expected = op.join('foo_artist','foo_album','09 - foo_title.mp3')
-        self.assertEqual(expected,self.MockGetNewName(self.Gen(attrs),model))
+        eq_(expected,self.MockGetNewName(self.Gen(attrs),model))
         model = '%genre%/%artist%/[%year%]%album%/%track% - %title%'
         expected = op.join('foo_genre','foo_artist','[2005]foo_album','09 - foo_title.mp3')
-        self.assertEqual(expected,self.MockGetNewName(self.Gen(attrs),model))
+        eq_(expected,self.MockGetNewName(self.Gen(attrs),model))
         model = '%artist%/%album% - %track% - %title%'
         expected = op.join('foo_artist','foo_album - 09 - foo_title.mp3')
-        self.assertEqual(expected,self.MockGetNewName(self.Gen(attrs),model))
+        eq_(expected,self.MockGetNewName(self.Gen(attrs),model))
 
     def test_invalid(self):
         attrs = {
             }
         model = '%artist%/%album%/%track% - %artist% - %invalid%'
         expected = op.join('foo_artist','foo_album','09 - foo_artist - (none).mp3')
-        self.assertEqual(expected,self.MockGetNewName(self.Gen(attrs),model))
+        eq_(expected,self.MockGetNewName(self.Gen(attrs),model))
         model = '%genre%/%album%/%track% - %artist% - %invalid%' #no genre in attrs
         expected = op.join('(none)','foo_album','09 - foo_artist - (none).mp3')
-        self.assertEqual(expected,self.MockGetNewName(self.Gen(attrs),model))
+        eq_(expected,self.MockGetNewName(self.Gen(attrs),model))
 
     def test_whitespace(self):
         attrs = {
             }
         model = '%artist%/%album%/%track% - %artist% - %title%'
         expected = op.join('foo artist','foo album','09 - foo artist - foo title.mp3')
-        self.assertEqual(expected,self.MockGetNewName(self.Gen(attrs),model,WS_UNDERSCORES_TO_SPACES))
+        eq_(expected,self.MockGetNewName(self.Gen(attrs),model,WS_UNDERSCORES_TO_SPACES))
         expected = op.join('foo_artist','foo_album','09 - foo_artist - foo_title.mp3')
-        self.assertEqual(expected,self.MockGetNewName(self.Gen(attrs),model,WS_SPACES_TO_UNDERSCORES))
+        eq_(expected,self.MockGetNewName(self.Gen(attrs),model,WS_SPACES_TO_UNDERSCORES))
 
     def test_no_extension(self):
         myfile = self.Gen({})
         myfile.name = 'foobar'
-        self.assertEqual('foobar',self.MockGetNewName(myfile,'%oldfilename%'))
+        eq_('foobar',self.MockGetNewName(myfile,'%oldfilename%'))
 
-class TCRestructureDirectory(TestCase):
+class TestRestructureDirectory:
     def Gen(self,attrs,parent,name):
         result = hsfs.music._File(parent,name + '.mp3')
         result._read_all_info()
             }
         file = self.Gen(attrs,dir,'foobar')
         result = RestructureDirectory(dir,'%artist%/%album%/%track% - %artist% - %title%')
-        self.assertEqual(1,len(result))
-        self.assertEqual('foo_artist',result[0].name)
-        self.assertEqual(1,len(result[0]))
-        self.assertEqual('foo_album',result[0][0].name)
-        self.assertEqual(1,len(result[0][0]))
-        self.assertEqual('09 - foo_artist - foo_title.mp3',result[0][0][0].name)
+        eq_(1,len(result))
+        eq_('foo_artist',result[0].name)
+        eq_(1,len(result[0]))
+        eq_('foo_album',result[0][0].name)
+        eq_(1,len(result[0][0]))
+        eq_('09 - foo_artist - foo_title.mp3',result[0][0][0].name)
     
     def test_conflict(self):
         dir = manualfs.Directory(None, 'root')
         self.Gen(attrs,dir,'foobar1')
         self.Gen(attrs,dir,'foobar2')
         result = RestructureDirectory(dir,'%artist%/%album%/%track% - %artist% - %title%')
-        self.assertEqual(1,len(result))
-        self.assertEqual('foo_artist',result[0].name)
-        self.assertEqual(1,len(result[0]))
-        self.assertEqual('foo_album',result[0][0].name)
-        self.assertEqual(2,len(result[0][0]))
-        self.assertEqual('09 - foo_artist - foo_title.mp3',result[0][0][0].name)
-        self.assertEqual('[000] 09 - foo_artist - foo_title.mp3',result[0][0][1].name)
+        eq_(1,len(result))
+        eq_('foo_artist',result[0].name)
+        eq_(1,len(result[0]))
+        eq_('foo_album',result[0][0].name)
+        eq_(2,len(result[0][0]))
+        eq_('09 - foo_artist - foo_title.mp3',result[0][0][0].name)
+        eq_('[000] 09 - foo_artist - foo_title.mp3',result[0][0][1].name)
     
     def test_slash_in_tokens(self):
         dir = manualfs.Directory(None, 'root')
             }
         file = self.Gen(attrs,dir,'foobar')
         result = RestructureDirectory(dir,'%artist%/%album%/%track% - %artist% - %title%')
-        self.assertEqual(1,len(result))
-        self.assertEqual('foo artist',result[0].name)
-        self.assertEqual(1,len(result[0]))
-        self.assertEqual('foo album',result[0][0].name)
-        self.assertEqual(1,len(result[0][0]))
-        self.assertEqual('09 - foo artist - foo title.mp3',result[0][0][0].name)
+        eq_(1,len(result))
+        eq_('foo artist',result[0].name)
+        eq_(1,len(result[0]))
+        eq_('foo album',result[0][0].name)
+        eq_(1,len(result[0][0]))
+        eq_('09 - foo artist - foo title.mp3',result[0][0][0].name)
     
     def test_groups(self):
         dir = manualfs.Directory(None, 'root')
         attrs = {'artist':'foo_artist',}
         file = self.Gen(attrs,dir,'foobar')
         result = RestructureDirectory(dir,'%group:artist%')
-        self.assertEqual('E-L.mp3',result[0].name)
+        eq_('E-L.mp3',result[0].name)
     
     def test_groups_lower(self):
         dir = manualfs.Directory(None, 'root')
         attrs = {'artist':'zoo_artist',}
         file = self.Gen(attrs,dir,'foobar')
         result = RestructureDirectory(dir,'%group:artist:emp:lower%')
-        self.assertEqual('p-z.mp3',result[0].name)
+        eq_('p-z.mp3',result[0].name)
     
     def test_groups_on_exact_step(self):
         dir = manualfs.Directory(None, 'root')
         attrs = {'artist':'roo_artist',}
         file = self.Gen(attrs,dir,'foobar')
         result = RestructureDirectory(dir,'%group:artist:emr:lower%')
-        self.assertEqual('r-z.mp3',result[0].name)
+        eq_('r-z.mp3',result[0].name)
     
     def test_groups_on_step_plus_one(self):
         dir = manualfs.Directory(None, 'root')
         attrs = {'artist':'soo_artist',}
         file = self.Gen(attrs,dir,'foobar')
         result = RestructureDirectory(dir,'%group:artist:emr:lower%')
-        self.assertEqual('r-z.mp3',result[0].name)
+        eq_('r-z.mp3',result[0].name)
     
     def test_groups_on_step_minus_one(self):
         dir = manualfs.Directory(None, 'root')
         attrs = {'artist':'qoo_artist',}
         file = self.Gen(attrs,dir,'foobar')
         result = RestructureDirectory(dir,'%group:artist:emr:lower%')
-        self.assertEqual('m-q.mp3',result[0].name)
+        eq_('m-q.mp3',result[0].name)
     
     def test_groups_genre(self):
         dir = manualfs.Directory(None, 'root')
         attrs = {'genre':'soo_genre',}
         file = self.Gen(attrs,dir,'foobar')
         result = RestructureDirectory(dir,'%group:genre:emr:lower%')
-        self.assertEqual('r-z.mp3',result[0].name)
+        eq_('r-z.mp3',result[0].name)
     
     def test_groups_out_of_range(self):
         dir = manualfs.Directory(None, 'root')
         attrs = {'artist':'(oo_artist',}
         file = self.Gen(attrs,dir,'foobar')
         result = RestructureDirectory(dir,'%group:artist:emr:lower%')
-        self.assertEqual('a-d.mp3',result[0].name)
+        eq_('a-d.mp3',result[0].name)
     
     def test_groups_empty(self):
         dir = manualfs.Directory(None, 'root')
         attrs = {'artist':'',}
         file = self.Gen(attrs,dir,'foobar')
         result = RestructureDirectory(dir,'%group:artist:emr:lower%')
-        self.assertEqual('a-d.mp3',result[0].name)
+        eq_('a-d.mp3',result[0].name)
     
     def test_firstletter_normal(self):
         dir = manualfs.Directory(None, 'root')
         attrs = {'artist':'foo_artist',}
         file = self.Gen(attrs,dir,'foobar')
         result = RestructureDirectory(dir,'%firstletter:artist%')
-        self.assertEqual('F.mp3',result[0].name)
+        eq_('F.mp3',result[0].name)
     
     def test_firstletter_album(self):
         dir = manualfs.Directory(None, 'root')
         attrs = {'album':'goo_album',}
         file = self.Gen(attrs,dir,'foobar')
         result = RestructureDirectory(dir,'%firstletter:album%')
-        self.assertEqual('G.mp3',result[0].name)
+        eq_('G.mp3',result[0].name)
     
     def test_firstletter_no_attr(self):
         dir = manualfs.Directory(None, 'root')
         attrs = {'artist':'foo_artist',}
         file = self.Gen(attrs,dir,'foobar')
         result = RestructureDirectory(dir,'%firstletter:album%')
-        self.assertEqual('(none).mp3',result[0].name)
+        eq_('(none).mp3',result[0].name)
     
     def test_firstletter_empty_attr(self):
         dir = manualfs.Directory(None, 'root')
         attrs = {'artist':'',}
         file = self.Gen(attrs,dir,'foobar')
         result = RestructureDirectory(dir,'%firstletter:artist%')
-        self.assertEqual('(none).mp3',result[0].name)
+        eq_('(none).mp3',result[0].name)
     
     def test_firstletter_lower(self):
         dir = manualfs.Directory(None, 'root')
         attrs = {'artist':'foo_artist',}
         file = self.Gen(attrs,dir,'foobar')
         result = RestructureDirectory(dir,'%firstletter:artist:lower%')
-        self.assertEqual('f.mp3',result[0].name)
+        eq_('f.mp3',result[0].name)
     
     def test_forbidden_chars(self):
         dir = manualfs.Directory(None, 'root')
             }
         file = self.Gen(attrs,dir,'foobar')
         result = RestructureDirectory(dir,'%genre%/%album%/%artist% - %title%')
-        self.assertEqual(1,len(result))
-        self.assertEqual('foo  genre',result[0].name)
-        self.assertEqual(1,len(result[0]))
-        self.assertEqual('foo  album',result[0][0].name)
-        self.assertEqual(1,len(result[0][0]))
-        self.assertEqual('foo  artist - foo  title.mp3',result[0][0][0].name)
+        eq_(1,len(result))
+        eq_('foo  genre',result[0].name)
+        eq_(1,len(result[0]))
+        eq_('foo  album',result[0][0].name)
+        eq_(1,len(result[0][0]))
+        eq_('foo  artist - foo  title.mp3',result[0][0][0].name)
     
     def test_weakref(self):
         dir = manualfs.Directory(None, 'root')
         del result
         copy.detach_copy(True)
         gc.collect()
-        self.assert_(w() is None)
+        assert w() is None
     
     def test_case_insensitive_option(self):
         dir = manualfs.Directory(None, 'root')
         attrs = {'artist':'FOO_ARTIST','title' :'t2'}
         file2 = self.Gen(attrs,dir,'foobar2')
         result = RestructureDirectory(dir,'%artist%/%title%',case_sensitive=False)
-        self.assertEqual(1,len(result))
-        self.assertEqual(2,len(result.allfiles))
+        eq_(1,len(result))
+        eq_(2,len(result.allfiles))
     
     def test_dont_rename_empty_tags(self):
         dir = manualfs.Directory(None, '')
             }
         file = self.Gen(attrs,subdir,'foobar')
         result = RestructureDirectory(dir,'%artist%/%album%/%track% - %artist% - %title%',rename_empty_tag=False)
-        self.assertEqual(1,len(result))
-        self.assertEqual('(not renamed)',result[0].name)
-        self.assertEqual(1,len(result[0]))
-        self.assertEqual('subdir',result[0][0].name)
-        self.assertEqual(1,len(result[0][0]))
-        self.assertEqual('foobar.mp3',result[0][0][0].name)
+        eq_(1,len(result))
+        eq_('(not renamed)',result[0].name)
+        eq_(1,len(result[0]))
+        eq_('subdir',result[0][0].name)
+        eq_(1,len(result[0][0]))
+        eq_('foobar.mp3',result[0][0][0].name)
     
     def test_backslashes_are_counted_as_slashes(self):
         #What happened here is that models containing backslashes could make 
         attrs = {'artist':'foo_artist','title' :'t1'}
         file = self.Gen(attrs,dir,'foobar')
         result = RestructureDirectory(dir,'%artist%\\%title%',parent_job=j)
-        self.assertEqual(100,self.progress)
+        eq_(100,self.progress)
     
 
-class TCSplit(TestCase):
+class TestSplit:
     def Gen(self,specs):
         #specs is a list of files you want to add to your virtual directory
         #Every item in specs must be a tuple like this:
         #A test that should return only one chunk
         ref = self.Gen([self._one_byte,self._one_byte])
         splitter = Split(ref,'CD %sequence%',700 * 1024 * 1024)
-        self.assertEqual(1,len(splitter))
-        self.assert_(ref[0].name in splitter[0])
-        self.assert_(ref[1].name in splitter[0])
+        eq_(1,len(splitter))
+        assert ref[0].name in splitter[0]
+        assert ref[1].name in splitter[0]
     
     def test_simple_two_chunk(self):
         #A test that should return two chunks with one file in each
         ref = self.Gen([self._one_byte,self._one_byte])
         splitter = Split(ref,'CD %sequence%',1)
-        self.assertEqual(2,len(splitter))
-        self.assert_(ref[0].name in splitter[0])
-        self.assert_(ref[1].name in splitter[1])
+        eq_(2,len(splitter))
+        assert ref[0].name in splitter[0]
+        assert ref[1].name in splitter[1]
     
     def test_file_too_big_for_chunk(self):
         #Test a case where a file would be too big even to fit alone in a
         #user of the Split to warn deal with these chunks appropriately.
         ref = self.Gen([self._one_byte,(None,2),self._one_byte])
         splitter = Split(ref,'CD %sequence%',2)
-        self.assertEqual(3,len(splitter))
-        self.assert_(ref[0].name in splitter[0])
-        self.assert_(ref[1].name in splitter[1])
-        self.assert_(ref[2].name in splitter[2])
+        eq_(3,len(splitter))
+        assert ref[0].name in splitter[0]
+        assert ref[1].name in splitter[1]
+        assert ref[2].name in splitter[2]
     
     def test_chunk_name_sequence(self):
         ref = self.Gen([self._one_byte,self._one_byte])
         splitter = Split(ref,'CD %sequence%',1)
-        self.assertEqual('CD 1',splitter[0].name)
-        self.assertEqual('CD 2',splitter[1].name)
+        eq_('CD 1',splitter[0].name)
+        eq_('CD 2',splitter[1].name)
     
     def test_chunk_name_item(self):
         ref = self.Gen([('abc',1),('def',1)])
         splitter = Split(ref,'CD %item:first% - %item:last%',2)
-        self.assertEqual('CD abc - def',splitter[0].name)
+        eq_('CD abc - def',splitter[0].name)
     
     def test_chunk_name_item_1st_letter(self):
         ref = self.Gen([('abc',1),('def',1)])
         splitter = Split(ref,'CD %item:first:1% - %item:last:1%',2)
-        self.assertEqual('CD a - d',splitter[0].name)
+        eq_('CD a - d',splitter[0].name)
     
     def test_chunk_name_item_2nd_letter(self):
         ref = self.Gen([('abc',1),('def',1)])
         splitter = Split(ref,'CD %item:first:2% - %item:last:2%',2)
-        self.assertEqual('CD ab - de',splitter[0].name)
+        eq_('CD ab - de',splitter[0].name)
 
     def test_chunk_name_item_invalid_letter(self):
         ref = self.Gen([('abc',1),('def',1)])
         splitter = Split(ref,'CD %item:first:invalid% - %item:last:invalid%',2)
-        self.assertEqual('CD abc - def',splitter[0].name)
+        eq_('CD abc - def',splitter[0].name)
     
     def test_invalid_model(self):
         ref = self.Gen([self._one_byte,self._one_byte])
         ref[0].artist = 'foobar_first'
         ref[1].artist = 'foobar_last'
         splitter = Split(ref,'CD %foobar% - %sequence:foobar:bleh% - %% - %artist% - %artist:foobar% - %artist:first:foobar% - %sequence%',2)
-        self.assertEqual('CD (none) - (none) - (none) - (none) - (none) - (none) - 1',splitter[0].name)
+        eq_('CD (none) - (none) - (none) - (none) - (none) - (none) - 1',splitter[0].name)
     
     def test_chunk_name_formatted_sequence(self):
         ref = self.Gen([self._one_byte,self._one_byte])
         splitter = Split(ref,'CD %sequence:3%',1)
-        self.assertEqual('CD 001',splitter[0].name)
-        self.assertEqual('CD 002',splitter[1].name)
+        eq_('CD 001',splitter[0].name)
+        eq_('CD 002',splitter[1].name)
     
     def test_chunk_name_conflict(self):
         ref = self.Gen([('foobar1',1),('foobar2',1)])
         splitter = Split(ref,'CD %item:first:1% - %item:last:1%',1)
-        self.assertEqual('CD f - f',splitter[0].name)
-        self.assertEqual('[000] CD f - f',splitter[1].name)
+        eq_('CD f - f',splitter[0].name)
+        eq_('[000] CD f - f',splitter[1].name)
     
     def test_that_structure_is_preserved(self):
         ref = self.Gen([self._one_byte,self._one_byte])
         ref.files[0].move(dir1)
         ref.files[0].move(dir2)
         splitter = Split(ref,'CD %sequence%',2)
-        self.assertEqual(1,len(splitter))
-        self.assertEqual(2,len(splitter[0]))
-        self.assertEqual('dir1',splitter[0][0].name)
-        self.assertEqual('dir2',splitter[0][1].name)
-        self.assertEqual('foobar_0',splitter[0][0][0].name)
-        self.assertEqual('foobar_1',splitter[0][1][0].name)
+        eq_(1,len(splitter))
+        eq_(2,len(splitter[0]))
+        eq_('dir1',splitter[0][0].name)
+        eq_('dir2',splitter[0][1].name)
+        eq_('foobar_0',splitter[0][0][0].name)
+        eq_('foobar_1',splitter[0][1][0].name)
     
     def test_grouping(self):
         ref = self.Gen([self._one_byte,self._one_byte,self._one_byte])
         f2.move(d2)
         f3.move(d2)
         splitter = Split(ref,'CD %sequence%',2)
-        self.assertEqual(2,len(splitter))
-        self.assert_(d1.name in splitter[0])
-        self.assert_(d2.name in splitter[0])
-        self.assert_(d2.name in splitter[1])
-        self.assert_(f1.name in splitter[0][0])
-        self.assert_(f2.name in splitter[0][1])
-        self.assert_(f3.name in splitter[1][0])
+        eq_(2,len(splitter))
+        assert d1.name in splitter[0]
+        assert d2.name in splitter[0]
+        assert d2.name in splitter[1]
+        assert f1.name in splitter[0][0]
+        assert f2.name in splitter[0][1]
+        assert f3.name in splitter[1][0]
         #now with grouping
         splitter = Split(ref,'CD %sequence%',2,1)
-        self.assertEqual(2,len(splitter))
-        self.assert_(d1.name in splitter[0])
-        self.assert_(d2.name not in splitter[0])
-        self.assert_(d2.name in splitter[1])
-        self.assert_(f1.name in splitter[0][0])
-        self.assert_(f2.name in splitter[1][0])
-        self.assert_(f3.name in splitter[1][0])
+        eq_(2,len(splitter))
+        assert d1.name in splitter[0]
+        assert d2.name not in splitter[0]
+        assert d2.name in splitter[1]
+        assert f1.name in splitter[0][0]
+        assert f2.name in splitter[1][0]
+        assert f3.name in splitter[1][0]
     
     def test_group_too_large(self):
         #What happens here is that the grouping level is at one, but one of the level 1
         f4.move(d22)
         splitter = Split(ref,'CD %sequence%',2,1)
         #There should be 3 cds, one with 'a', one with 'b', and another one with 'b'
-        self.assertEqual(3,len(splitter))
-        self.assert_(d1.name in splitter[0])
-        self.assert_(d2.name not in splitter[0])
-        self.assert_(d2.name in splitter[1])
-        self.assert_(d2.name in splitter[2])
-        self.assert_(d21.name in splitter[1][0])
-        self.assert_(d22.name in splitter[2][0])
-        self.assert_(f1.name in splitter[0][0])
-        self.assert_(f2.name in splitter[1][0][0])
-        self.assert_(f3.name in splitter[1][0][0])
-        self.assert_(f4.name in splitter[2][0][0])
+        eq_(3,len(splitter))
+        assert d1.name in splitter[0]
+        assert d2.name not in splitter[0]
+        assert d2.name in splitter[1]
+        assert d2.name in splitter[2]
+        assert d21.name in splitter[1][0]
+        assert d22.name in splitter[2][0]
+        assert f1.name in splitter[0][0]
+        assert f2.name in splitter[1][0][0]
+        assert f3.name in splitter[1][0][0]
+        assert f4.name in splitter[2][0][0]
     
     def test_forbidden_chars(self):
         ref = self.Gen([('a|:<>',1),('b?\\/*',1)])
         splitter = Split(ref,'CD %item:first% - %item:last%',2)
-        self.assertEqual('CD a - b',splitter[0].name)
+        eq_('CD a - b',splitter[0].name)
     
     def test_file_that_is_higher_than_the_grouping_level(self):
         # if a file is in root of refdir when grouping level is 0, we want that
         ref = manualfs.Directory(None, '')
         ref.new_file('foobar')
         splitted = Split(ref,'CD %sequence%',1,1)
-        self.assertEqual('foobar',splitted[0][0].name)
+        eq_('foobar',splitted[0][0].name)
     
     def test_file_too_large_dont_create_new_chunk_if_current_one_is_empty(self):
         ref = self.Gen([(None,2)])
         splitted = Split(ref,'foo',1)
-        self.assertEqual(1,len(splitted))
+        eq_(1,len(splitted))
     
 
-class TCBatchOperation(TestCase):
-    def setUp(self):
-        self.rootpath = self.tmpdir()
+class TestBatchOperation:
+    def pytest_funcarg__dosetup(self, request):
+        tmpdir = request.getfuncargvalue('tmpdir')
+        self.rootpath = str(tmpdir)
         self.testpath = create_fake_fs(self.rootpath)
         ref = phys.Directory(None, self.testpath)
         copy = manualfs.Directory(None, '')
         self.ref = ref
         self.copy = copy
     
-    def test_main(self):
+    def test_main(self, dosetup):
         self.copy['file1.test'].name = 'foobar'
         self.copy['dir1'].name = 'foobar_dir'
         bo = BatchOperation(self.copy,self.testpath)
         bo.rename()
         ref = phys.Directory(None,self.testpath)
-        self.assert_('foobar' in ref)
-        self.assert_('file1.test' not in ref)
-        self.assert_('foobar_dir' in ref)
-        self.assert_('file1.test' in ref['foobar_dir'])
+        assert 'foobar' in ref
+        assert 'file1.test' not in ref
+        assert 'foobar_dir' in ref
+        assert 'file1.test' in ref['foobar_dir']
     
-    def test_copy_has_a_name(self):
+    def test_copy_has_a_name(self, dosetup):
         #The name of the root copy dir must not be included in the rename.
         self.copy.name = 'foobar'
         self.copy['file1.test'].name = 'foobar'
         bo = BatchOperation(self.copy,self.testpath)
         bo.rename()
         ref = phys.Directory(None,self.testpath)
-        self.assert_('foobar' in ref)
-        self.assert_('file1.test' not in ref)
+        assert 'foobar' in ref
+        assert 'file1.test' not in ref
     
-    def test_copy_instead_of_move(self):
+    def test_copy_instead_of_move(self, dosetup):
         self.copy['file1.test'].name = 'foobar'
         self.copy['dir1'].name = 'foobar_dir'
         bo = BatchOperation(self.copy,self.testpath)
         bo.copy()
         ref = phys.Directory(None,self.testpath)
-        self.assert_('foobar' in ref)
-        self.assert_('file1.test' in ref)
-        self.assert_('foobar_dir' in ref)
-        self.assert_('file1.test' in ref['foobar_dir'])
-        self.assert_('file1.test' in ref['dir1'])
+        assert 'foobar' in ref
+        assert 'file1.test' in ref
+        assert 'foobar_dir' in ref
+        assert 'file1.test' in ref['foobar_dir']
+        assert 'file1.test' in ref['dir1']
     
-    def test_empty(self):
+    def test_empty(self, dosetup):
         bo = BatchOperation(TestDir(None,''),'foobar')
-        self.assertEqual([],bo.name_list)
+        eq_([],bo.name_list)
     
-    def test_simple(self):
+    def test_simple(self, dosetup):
         ref = TestDir(None,'reference')
         ref.AddDir('dir').AddFile('subfile')
         ref.AddFile('file')
             (Path(('reference','file')),Path(('destination','file'))),
             (Path(('reference','dir','subfile')),Path(('destination','dir','subfile'))),
         ]
-        self.assertEqual(expected,bo.name_list)
+        eq_(expected,bo.name_list)
     
-    def test_source_same_as_dest(self):
+    def test_source_same_as_dest(self, dosetup):
         ref = TestDir(None,'reference')
         ref.AddDir('dir').AddFile('subfile')
         ref.AddFile('file')
         copy.files[0].rename('renamed')
         bo = BatchOperation(copy,Path('reference'))
         expected = [(Path(('reference','file')),Path(('reference','renamed')))]
-        self.assertEqual(expected,bo.name_list)
+        eq_(expected,bo.name_list)
     
-    def test_renamed_as_list(self):
+    def test_renamed_as_list(self, dosetup):
         ref = TestDir(None,'reference')
         ref.AddDir('dir').AddFile('subfile')
         ref.AddFile('file')
             (Path(('reference','file')),Path(('destination','file'))),
             (Path(('reference','dir','subfile')),Path(('destination','dir','subfile'))),
         ]
-        self.assertEqual(expected,bo.name_list)
+        eq_(expected,bo.name_list)
     
-    def test_cdrom_volume_name_list(self):
+    def test_cdrom_volume_name_list(self, dosetup):
         #ABOUT CD PROCESSING
         #
         #When the original song of a song in renamed is a children of a
         renamed = manualfs.Directory(None, '')
         renamed.copy(volume)
         bo = BatchOperation(renamed,Path(('','foobar')))
-        self.assertEqual(3,len(bo.name_list))
-        self.assertEqual(('!volume','fs','file1.test'),bo.name_list[0][0])
-        self.assertEqual(('','foobar','fs','file1.test'),bo.name_list[0][1])
-        self.assertEqual(('!volume','fs','file2.test'),bo.name_list[1][0])
-        self.assertEqual(('','foobar','fs','file2.test'),bo.name_list[1][1])
-        self.assertEqual(('!volume','fs','file3.test'),bo.name_list[2][0])
-        self.assertEqual(('','foobar','fs','file3.test'),bo.name_list[2][1])
+        eq_(3,len(bo.name_list))
+        eq_(('!volume','fs','file1.test'),bo.name_list[0][0])
+        eq_(('','foobar','fs','file1.test'),bo.name_list[0][1])
+        eq_(('!volume','fs','file2.test'),bo.name_list[1][0])
+        eq_(('','foobar','fs','file2.test'),bo.name_list[1][1])
+        eq_(('!volume','fs','file3.test'),bo.name_list[2][0])
+        eq_(('','foobar','fs','file3.test'),bo.name_list[2][1])
     
-    def test_copy_tokenized_path(self):
+    def test_copy_tokenized_path(self, dosetup, tmpdir):
         def OnNeedCD(location):
-            self.assert_(location is volume)
+            assert location is volume
             return Path(self.rootpath)
         
-        copypath = self.tmpdir()
+        copypath = str(tmpdir)
         root = Root(threaded=False)
         volume = root.new_directory('volume')
         volume.vol_type = VOLTYPE_CDROM
         bo.OnNeedCD = OnNeedCD
         bo.copy()
         result = phys.Directory(None,copypath)
-        self.assertEqual(1,len(result))
-        self.assertEqual('fs',result[0].name)
+        eq_(1,len(result))
+        eq_('fs',result[0].name)
     
-    def test_with_job(self):
+    def test_with_job(self, dosetup):
         def update(progress,description=''):
             self.log.append(progress)
             return True
         bo = BatchOperation(self.copy,self.testpath)
         self.log = []
         job = Job(1,update)
-        self.assert_(bo.copy(job))
+        assert bo.copy(job)
         expected_log = [0, 0, 50, 100]
-        self.assertEqual(expected_log,self.log)
+        eq_(expected_log,self.log)
     
-    def test_OnNeedCD_returns_none(self):
+    def test_OnNeedCD_returns_none(self, dosetup, tmpdir):
         def OnNeedCD(location):
             return
         
-        copypath = self.tmpdir()
+        copypath = str(tmpdir.join('copypath'))
+        os.mkdir(copypath)
         root = Root(threaded=False)
         volume = root.new_directory('volume')
         volume.vol_type = VOLTYPE_CDROM
         renamed.copy(volume)
         bo = BatchOperation(renamed,Path(copypath))
         bo.OnNeedCD = OnNeedCD
-        self.assert_(not bo.copy())
+        assert not bo.copy()
         result = phys.Directory(None,copypath)
-        self.assertEqual(0,len(result))
+        eq_(0,len(result))
     
-    def test_with_job_cancel(self):
+    def test_with_job_cancel(self, dosetup):
         def update(progress,description=''):
             self.log.append(progress)
             return progress < 50
         bo = BatchOperation(self.copy,self.testpath)
         self.log = []
         job = Job(1,update)
-        self.assert_(not bo.rename(job))
+        assert not bo.rename(job)
         expected_log = [0, 0, 50]
-        self.assertEqual(expected_log,self.log)
+        eq_(expected_log,self.log)
     
-    def test_with_ioerror(self):
+    def test_with_ioerror(self, dosetup):
         #When not copying from CDs, operation throwing IOError should just
         #skip the operation and go to the next file.
         fake_file = manualfs.File(self.copy, 'fake_file')
         fake_original_file = manualfs.File(fake_original_dir, 'fake_file')
         fake_file.copy(fake_original_file)
         bo = BatchOperation(self.copy,self.testpath)
-        self.assert_(bo.copy())
+        assert bo.copy()
     
-    def test_with_ioerror_cd(self):
+    def test_with_ioerror_cd(self, dosetup, tmpdir):
         #When copying from CDs, operation throwing IOError should call OnNeedCD
         #until the file is found or the whole operation is cancelled.
         def OnNeedCD(location):
             self.need_cd_calls += 1
             if self.need_cd_calls == 3:
                 return
-            self.assert_(location is volume)
+            assert location is volume
             return self.rootpath
         
         root = Root(threaded=False)
         dir.new_file('fake')
         renamed = manualfs.Directory(None, '')
         renamed.copy(volume)
-        bo = BatchOperation(renamed,Path(self.tmpdir()))
+        bo = BatchOperation(renamed,Path(str(tmpdir)))
         self.need_cd_calls = 0
         bo.OnNeedCD = OnNeedCD
-        self.assert_(not bo.copy())
-        self.assertEqual(3,self.need_cd_calls)
+        assert not bo.copy()
+        eq_(3,self.need_cd_calls)
     
-    def test_cd_copy_with_job(self):
+    def test_cd_copy_with_job(self, dosetup, tmpdir):
         def OnNeedCD(location):
-            self.assert_(location is volume)
+            assert location is volume
             return Path(self.rootpath)
         
         def update(progress,description=''):
         dir.new_file('file3.test')
         renamed = manualfs.Directory(None, '')
         renamed.copy(volume)
-        bo = BatchOperation(renamed,Path(self.tmpdir()))
+        bo = BatchOperation(renamed,Path(str(tmpdir)))
         bo.OnNeedCD = OnNeedCD
         self.log = []
         job = Job(1,update)
-        self.assert_(bo.copy(job))
+        assert bo.copy(job)
         expected_log = [0, 0, 33, 66, 100]
-        self.assertEqual(expected_log,self.log)
+        eq_(expected_log,self.log)
     
-    def test_cd_copy_OnNeedCD_returns_string(self):
+    def test_cd_copy_OnNeedCD_returns_string(self, dosetup, tmpdir):
         #When OnNeedCD returns a string instead of a path, BO must work properly.
         root = Root(threaded=False)
         volume = root.new_directory('volume')
         dir.new_file('file3.test')
         renamed = manualfs.Directory(None, '')
         renamed.copy(volume)
-        bo = BatchOperation(renamed,Path(self.tmpdir()))
+        bo = BatchOperation(renamed,Path(str(tmpdir)))
         bo.OnNeedCD = lambda location: self.rootpath
-        self.assert_(bo.copy())
+        assert bo.copy()
     
-    def test_cd_move(self):
+    def test_cd_move(self, dosetup, tmpdir):
         #When it's cd operation, we should ALWAYS copy.
         def OnNeedCD(location):
-            self.assert_(location is volume)
+            assert location is volume
             return Path(self.testpath)
         
         root = Root(threaded=False)
         volume.new_file('file1.test')
         renamed = manualfs.Directory(None, '')
         renamed.copy(volume)
-        bo = BatchOperation(renamed,Path(self.tmpdir()))
+        bo = BatchOperation(renamed,Path(str(tmpdir)))
         bo.OnNeedCD = OnNeedCD
-        self.assert_(bo.rename())
-        self.assert_(op.exists(op.join(self.testpath,'file1.test')))
+        assert bo.rename()
+        assert op.exists(op.join(self.testpath,'file1.test'))
     
-    def test_rename_conflicts(self):
+    def test_rename_conflicts(self, dosetup):
         copy = self.copy
         file1 = copy['file1.test']
         file2 = copy['file2.test']
         bo = BatchOperation(copy,Path(self.testpath))
         bo.rename()
         ref = phys.Directory(None,self.testpath)
-        self.assertEqual(2,ref['file1.test'].size)
-        self.assertEqual(1,ref['file2.test'].size)
+        eq_(2,ref['file1.test'].size)
+        eq_(1,ref['file2.test'].size)
     
-    def test_rename_unresolved_conflict(self):
-        copypath = self.tmpdir(self.testpath)
+    def test_rename_unresolved_conflict(self, dosetup, tmpdir):
+        copypath = str(tmpdir.join('copypath'))
+        shutil.copytree(self.testpath, copypath)
         bo = BatchOperation(self.copy,Path(copypath))
         #every file will be in conflict, but the conflict will not be resolved.
         bo.rename()
         tmpdir = phys.Directory(None,self.testpath)
-        self.assert_('file1.test' in tmpdir)
+        assert 'file1.test' in tmpdir
     
-    def test_ProcessNormalList_catches_OSError_and_issue_warning(self):
+    def test_ProcessNormalList_catches_OSError_and_issue_warning(self, dosetup, tmpdir, monkeypatch):
         def FakeMove(_, __):
             raise OSError()
         
-        self.mock(shutil, 'move', FakeMove)
-        self.mock(sys, 'stdout', StringIO())
-        self.assert_(sys.stdout.tell() == 0)
+        monkeypatch.setattr(shutil, 'move', FakeMove)
+        monkeypatch.setattr(sys, 'stdout', StringIO())
+        assert sys.stdout.tell() == 0
         bo = BatchOperation(self.copy, Path('foo'))
-        rootpath = Path(self.tmpdir())
+        rootpath = Path(str(tmpdir))
         source = rootpath + 'zerofile'
         dest = rootpath + 'foo_zero'
         open(str(source), 'w').close() # He want the file to exist so the move call is made.
             bo._BatchOperation__ProcessNormalList([(source, dest)], False)
         except OSError:
             self.fail()
-        self.assert_(sys.stdout.tell() > 0)
+        assert sys.stdout.tell() > 0
     
 
-class TCBatchOperation_unicode(TestCase):
-        # Path instances should only be "rendered" as unicode(), not str()
-    def setUp(self):
-        self.mock(sys, 'getfilesystemencoding', lambda: 'ascii') # force a failure on any non-ascii char
-        testpath = self.tmppath()
+class TestBatchOperation_unicode:
+    # Path instances should only be "rendered" as unicode(), not str()
+    def pytest_funcarg__dosetup(self, request):
+        monkeypatch = request.getfuncargvalue('monkeypatch')
+        tmpdir = request.getfuncargvalue('tmpdir')
+        monkeypatch.setattr(sys, 'getfilesystemencoding', lambda: 'ascii') # force a failure on any non-ascii char
+        testpath = Path(str(tmpdir))
         create_unicode_test_dir(testpath)
         sourcedir = phys.Directory(None, str(testpath))
         copy = manualfs.Directory(None, '')
         copy.copy(sourcedir)
-        destpath = Path(self.tmpdir())
+        destpath = Path(str(tmpdir))
         self.sourcedircopy = copy
         self.destpath = destpath
         
-    def test_copy(self):
+    def test_copy(self, dosetup):
         bo = BatchOperation(self.sourcedircopy, self.destpath)
         try:
             bo.copy()
         except UnicodeEncodeError:
             self.fail()
     
-    def test_rename(self):
+    def test_rename(self, dosetup):
         bo = BatchOperation(self.sourcedircopy, self.destpath)
         try:
             bo.rename()
         except UnicodeEncodeError:
             self.fail()
     
-    def test_warning(self):
+    def test_warning(self, dosetup, monkeypatch):
         def FakeMove(_, __):
             raise OSError()
         
-        self.mock(shutil, 'move', FakeMove)
-        self.mock(sys, 'stdout', StringIO())
+        monkeypatch.setattr(shutil, 'move', FakeMove)
+        monkeypatch.setattr(sys, 'stdout', StringIO())
         bo = BatchOperation(self.sourcedircopy, self.destpath)
         try:
             bo.rename()
             self.fail()
     
 
-class TCFSBuffer(TestCase):
+class TestFSBuffer:
     def test_empty(self):
         buf = Buffer(5)
-        self.assertEqual(5,buf.size)
-        self.assertEqual([],buf.DoBufferingFor(''))
-        self.assertEqual([],buf.content)
-        self.assertEqual(0,buf.space_taken)
-        self.assertEqual(5,buf.space_left)
+        eq_(5,buf.size)
+        eq_([],buf.DoBufferingFor(''))
+        eq_([],buf.content)
+        eq_(0,buf.space_taken)
+        eq_(5,buf.space_left)
     
     def test_one_dest(self):
         #buf only has one dest, so the process is quite straightforward.
             (file3,'source2','dest1',1),
         )
         buf.AddFiles(files)
-        self.assertEqual(0,buf.space_taken)
-        self.assertEqual(3,buf.space_left)
+        eq_(0,buf.space_taken)
+        eq_(3,buf.space_left)
         expected = [(file1,'source1','dest1',1),(file2,'source2','dest1',1),(file3,'source2','dest1',1)]
-        self.assertEqual(expected,buf.DoBufferingFor('dest1'))
-        self.assertEqual(expected,buf.content)
-        self.assertEqual(3,buf.space_taken)
-        self.assertEqual(0,buf.space_left)
-        self.assertEqual(expected,buf.PurgeBufferOf('dest1'))
-        self.assertEqual([],buf.content)
-        self.assertEqual(0,buf.space_taken)
-        self.assertEqual(3,buf.space_left)
+        eq_(expected,buf.DoBufferingFor('dest1'))
+        eq_(expected,buf.content)
+        eq_(3,buf.space_taken)
+        eq_(0,buf.space_left)
+        eq_(expected,buf.PurgeBufferOf('dest1'))
+        eq_([],buf.content)
+        eq_(0,buf.space_taken)
+        eq_(3,buf.space_left)
     
     def test_get_sources_get_destinations(self):
         buf = Buffer(3)
             (file3,'source2','dest2',1),
         )
         expected = ['source1','source2']
-        self.assertEqual(expected,buf.GetSources(files))
+        eq_(expected,buf.GetSources(files))
         expected = ['dest1','dest2']
-        self.assertEqual(expected,buf.GetDestinations(files))
+        eq_(expected,buf.GetDestinations(files))
     
     def test_two_dest_enough_space(self):
         #Here, we have 2 dests, and enough space to hold every files. Thus,
         )
         buf.AddFiles(files)
         expected = [(file1,'source1','dest1',1),(file2,'source2','dest1',1),(file3,'source2','dest2',1)]
-        self.assertEqual(expected,buf.DoBufferingFor('dest1'))
-        self.assertEqual(expected,buf.content)
+        eq_(expected,buf.DoBufferingFor('dest1'))
+        eq_(expected,buf.content)
         expected = [(file1,'source1','dest1',1),(file2,'source2','dest1',1)]
-        self.assertEqual(expected,buf.PurgeBufferOf('dest1'))
+        eq_(expected,buf.PurgeBufferOf('dest1'))
         expected = [(file3,'source2','dest2',1)]
-        self.assertEqual(expected,buf.content)
-        self.assertEqual([],buf.DoBufferingFor('dest2'))
-        self.assertEqual(expected,buf.content)
-        self.assertEqual(expected,buf.PurgeBufferOf('dest2'))
-        self.assertEqual([],buf.content)
+        eq_(expected,buf.content)
+        eq_([],buf.DoBufferingFor('dest2'))
+        eq_(expected,buf.content)
+        eq_(expected,buf.PurgeBufferOf('dest2'))
+        eq_([],buf.content)
     
     def test_two_dest_not_enough_space(self):
         #Here, we have 2 dests, and notenough space to hold every files. Thus,
         )
         buf.AddFiles(files)
         expected = [(file1,'source1','dest1',1),(file2,'source2','dest1',1)]
-        self.assertEqual(expected,buf.DoBufferingFor('dest1'))
-        self.assertEqual(expected,buf.content)
-        self.assertEqual(expected,buf.PurgeBufferOf('dest1'))
+        eq_(expected,buf.DoBufferingFor('dest1'))
+        eq_(expected,buf.content)
+        eq_(expected,buf.PurgeBufferOf('dest1'))
         expected = [(file3,'source2','dest2',1)]
-        self.assertEqual([],buf.content)
-        self.assertEqual(expected,buf.DoBufferingFor('dest2'))
-        self.assertEqual(expected,buf.content)
-        self.assertEqual(expected,buf.PurgeBufferOf('dest2'))
-        self.assertEqual([],buf.content)
+        eq_([],buf.content)
+        eq_(expected,buf.DoBufferingFor('dest2'))
+        eq_(expected,buf.content)
+        eq_(expected,buf.PurgeBufferOf('dest2'))
+        eq_([],buf.content)
     
     def test_get_bytes_required(self):
         buf = Buffer(2)
             (file3,'source2','dest2',1),
         )
         buf.AddFiles(files)
-        self.assertEqual(3,buf.GetMinimumBytesRequired())
-        self.assertEqual(4,buf.GetMaximumBytesRequired())
+        eq_(3,buf.GetMinimumBytesRequired())
+        eq_(4,buf.GetMaximumBytesRequired())
     
     def test_set_size(self):
         buf = Buffer(5)
         )
         buf.AddFiles(files)
         buf.DoBufferingFor('dest1')
-        self.assertEqual(5,buf.size)
-        self.assertEqual(4,buf.space_taken)
-        self.assertEqual(1,buf.space_left)
+        eq_(5,buf.size)
+        eq_(4,buf.space_taken)
+        eq_(1,buf.space_left)
         buf.size = 10
-        self.assertEqual(10,buf.size)
-        self.assertEqual(4,buf.space_taken)
-        self.assertEqual(6,buf.space_left)
+        eq_(10,buf.size)
+        eq_(4,buf.space_taken)
+        eq_(6,buf.space_left)
     

core/sqlfs/music_test.py

 from hsfs.phys import music
 from hscommon.path import Path
 from jobprogress.job import Job, JobCancelled
+from hscommon.testutil import eq_
 
-from ..testcase import TestCase
+from ..testutil import testdata
 from .. import manualfs
 from .music import *
 
-class TCRoot_children(TestCase):
+class TestRoot_children:
     def test_new_directories_are_Volume(self):
         root = Root(threaded=False)
         v = root.new_directory('foo')
-        self.assert_(type(v) is Volume)
+        assert type(v) is Volume
     
     def test_new_files_are_music_File(self):
         root = Root(threaded=False)
         f = root.new_file('file')
-        self.assert_(type(f) is File)
+        assert type(f) is File
 
-class TCVolume_children(TestCase):
+class TestVolume_children:
     def test_new_directories_are_music_Directory(self):
         root = Root(threaded=False)
         v = root.new_directory('foo')
         d = v.new_directory('bar')
-        self.assert_(type(d) is Directory)
+        assert type(d) is Directory
     
     def test_new_files_are_music_File(self):
         root = Root(threaded=False)
         v = root.new_directory('foo')
         f = v.new_file('file')
-        self.assert_(type(f) is File)
+        assert type(f) is File
 
-class TCDirectory_children(TestCase):
+class TestDirectory_children:
     def test_new_files_are_music_File(self):
         root = Root(threaded=False)
         v = root.new_directory('foo')
         d = v.new_directory('bar')
         f = d.new_file('file')
-        self.assert_(type(f) is File)
+        assert type(f) is File
     
 
-class TCVolume_initial_path(TestCase):
+class TestVolume_initial_path:
     def test_initial_path(self):
         p = Path(('foo','bar'))
         root = Root(threaded=False)
         v = root.new_directory('foo')
         v.initial_path = p
         result = v.initial_path
-        self.assertEqual(p,result)
-        self.assert_(isinstance(result,Path))
+        eq_(p,result)
+        assert isinstance(result,Path)
     
-    def test_initial_path_persistence(self):
+    def test_initial_path_persistence(self, tmpdir):
         p = Path(('foo','bar'))
-        dbpath = op.join(self.tmpdir(),'fs.db')
+        dbpath = str(tmpdir.join('fs.db'))
         root = Root(dbpath, threaded=False)
         v = root.new_directory('foo')
         v.initial_path = p
         root.con.close()
         root = Root(dbpath, threaded=False)
         v = root[0]
-        self.assertEqual(p,v.initial_path)
+        eq_(p,v.initial_path)
     
     def test_keep_initial_path_cache(self):
         p = Path(('foo','bar'))
         v = root.new_directory('foo')
         v.initial_path = p
         p = v.initial_path
-        self.assert_(v.initial_path is p)
+        assert v.initial_path is p
     
     def test_invalidate_cache_on_set(self):
         p = Path(('foo','bar'))
         root = Root(threaded=False)
         v = root.new_directory('foo')
         v.initial_path = p
-        self.assertEqual(p,v.initial_path)
+        eq_(p,v.initial_path)
         p = Path(('foo','baz'))
         v.initial_path = p
-        self.assertEqual(p,v.initial_path)
+        eq_(p,v.initial_path)
     
     def test_initial_value(self):
         root = Root(threaded=False)
         v = root.new_directory('foo')
-        self.assertEqual(Path(''),v.initial_path)
+        eq_(Path(''),v.initial_path)
     
 
-class TCVolume_vol_type(TestCase):
+class TestVolume_vol_type:
     def test_vol_type(self):
         root = Root(threaded=False)
         v = root.new_directory('foo')
         v.vol_type = VOLTYPE_FIXED
-        self.assertEqual(VOLTYPE_FIXED,v.vol_type)
+        eq_(VOLTYPE_FIXED,v.vol_type)
     
-    def test_vol_type_persistence(self):
-        dbpath = op.join(self.tmpdir(),'fs.db')
+    def test_vol_type_persistence(self, tmpdir):
+        dbpath = str(tmpdir.join('fs.db'))
         root = Root(dbpath, threaded=False)
         v = root.new_directory('foo')
         v.vol_type = VOLTYPE_FIXED
         root = Root(dbpath, threaded=False)
         v = root[0]
-        self.assertEqual(VOLTYPE_FIXED,v.vol_type)
+        eq_(VOLTYPE_FIXED,v.vol_type)
     
     def test_initial_value(self):
         root = Root(threaded=False)
         v = root.new_directory('foo')
-        self.assertEqual(VOLTYPE_FIXED,v.vol_type)
+        eq_(VOLTYPE_FIXED,v.vol_type)
     
 
-class TCVolume_physical_path(TestCase):
+class TestVolume_physical_path:
     def test_on_fixed_drive(self):
         root = Root(threaded=False)
         v = root.new_directory('foo')
         v.initial_path = Path(('foo','bar'))
-        self.assertEqual(v.initial_path,v.physical_path)
+        eq_(v.initial_path,v.physical_path)
     
 
-class TCDirectory_physical_path(TestCase):
+class TestDirectory_physical_path:
     def test_typical(self):
         root = Root(threaded=False)
         v = root.new_directory('foo')
         d = v.new_directory('bar')
         v.initial_path = Path(('initial','path'))
-        self.assertEqual(('','foo','bar'),d.path)
-        self.assertEqual(('initial','path','bar'),d.physical_path)
+        eq_(('','foo','bar'),d.path)
+        eq_(('initial','path','bar'),d.physical_path)
     
 
-class TCFile_physical_path(TestCase):
+class TestFile_physical_path:
     def test_typical(self):
         root = Root(threaded=False)
         v = root.new_directory('foo')
         d = v.new_directory('bar')
         f = d.new_file('baz')
         v.initial_path = Path(('initial','path'))
-        self.assertEqual(('','foo','bar','baz'),f.path)
-        self.assertEqual(('initial','path','bar','baz'),f.physical_path)
+        eq_(('','foo','bar','baz'),f.path)
+        eq_(('initial','path','bar','baz'),f.physical_path)
     
 
-class TCadd_volume(TestCase):
+class Testadd_volume:
     def _get_ref_dir(self):
         ref = manualfs.Directory(None,'initial')
         ref.new_directory('dir')
         root = Root(threaded=False)
         ref = self._get_ref_dir()
         v = root.add_volume(ref,'volume_name',42)
-        self.assert_(v in root)
-        self.assertEqual('volume_name',v.name)
-        self.assertEqual(1,v.dircount)
-        self.assertEqual(1,v.filecount)
-        self.assertEqual(42,v.vol_type)
-        self.assertEqual('initial',v.initial_path)
+        assert v in root
+        eq_('volume_name',v.name)
+        eq_(1,v.dircount)
+        eq_(1,v.filecount)
+        eq_(42,v.vol_type)
+        eq_('initial',v.initial_path)
     
     def test_job_cancel(self):
         j = Job(1, lambda progress: False) # Will cancel right away
         except JobCancelled:
             pass # This is expected
         # Nothing should have been added
-        self.assertEqual(0, len(root))
+        eq_(0, len(root))
     
 
-class TCVolume_Update(TestCase):
-    def test_that_ref_is_automatically_created(self):
-        ref_dir = self.filepath('ogg')
-        ref_dir = self.tmpdir(ref_dir)
+class TestVolume_Update:
+    def test_that_ref_is_automatically_created(self, tmpdir):
+        ogg_dir = testdata.filepath('ogg')
+        ref_dir = str(tmpdir.join('ref_dir'))
+        shutil.copytree(ogg_dir, ref_dir)
         ref = music.Directory(None,ref_dir)
         root = Root(threaded=False)
         v = root.add_volume(ref,'the_volume',VOLTYPE_FIXED)
-        self.assertEqual(2,v.filecount)
+        eq_(2,v.filecount)
         shutil.copy(op.join(ref_dir,'test1.ogg'),op.join(ref_dir,'test3.ogg'))
         v.update()
-        self.assertEqual(3,v.filecount)
+        eq_(3,v.filecount)
     
-    def test_that_the_ref_create_is_a_music_dir(self):
-        ref_dir = self.filepath('ogg')
-        ref_dir = self.tmpdir(ref_dir)
+    def test_that_the_ref_create_is_a_music_dir(self, tmpdir):
+        ogg_dir = testdata.filepath('ogg')
+        ref_dir = str(tmpdir.join('ref_dir'))
+        shutil.copytree(ogg_dir, ref_dir)
         ref = music.Directory(None,ref_dir)
         root = Root(threaded=False)
         v = root.add_volume(ref,'the_volume',VOLTYPE_FIXED)
-        self.assertEqual(2,v.filecount)
+        eq_(2,v.filecount)
         shutil.copy(op.join(ref_dir,'test1.ogg'),op.join(ref_dir,'test3.foo'))
         v.update()
-        self.assertEqual(2,v.filecount)
+        eq_(2,v.filecount)
     
     def test_gracefully_handle_invalid_path(self):
         # Sometimes, the volume is from an external drive and that drive is not plugged in.
             self.fail()
     
 
-class TCRoot_update_volumes(TestCase):
-    def test_only_update_fixed_volumes(self):
-        ref_dir = self.filepath('ogg')
-        ref_dir = self.tmpdir(ref_dir)
+class TestRoot_update_volumes:
+    def test_only_update_fixed_volumes(self, tmpdir):
+        ogg_dir = testdata.filepath('ogg')
+        ref_dir = str(tmpdir.join('ref_dir'))
+        shutil.copytree(ogg_dir, ref_dir)
         ref = music.Directory(None,ref_dir)
         root = Root(threaded=False)
         vf = root.add_volume(ref,'fixed',VOLTYPE_FIXED)
         vc = root.add_volume(ref,'cdrom',VOLTYPE_CDROM)
         shutil.copy(op.join(ref_dir,'test1.ogg'),op.join(ref_dir,'test3.ogg'))
         root.update_volumes()
-        self.assertEqual(3,vf.filecount)
-        self.assertEqual(2,vc.filecount)
+        eq_(3,vf.filecount)
+        eq_(2,vc.filecount)
     
 
-class TCJobs(TestCase):
-    def setUp(self):
+class TestJobs:
+    def setup_method(self, method):
         def callback(progress):
             self.log.append(progress)
             return True
         self.job = Job(1,callback)
     
     def do_test_log(self):
-        self.assertEqual(0,self.log[0])
-        self.assertEqual(100,self.log[-1])
+        eq_(0,self.log[0])
+        eq_(100,self.log[-1])
     
     def test_Volume_Update(self):
         root = Root(threaded=False)
     
     def test_Root_update_volumes(self):
         root = Root(threaded=False)
-        ref_dir = self.filepath('ogg')
+        ref_dir = testdata.filepath('ogg')
         v = root.new_directory('foo')
         v.initial_path = Path(ref_dir)
         v.vol_type = VOLTYPE_FIXED
         self.do_test_log()
     
 
-class TCparent_volume(TestCase):
+class Testparent_volume:
     def test_from_volume(self):
         root = Root(threaded=False)
         v = root.new_directory('foo')
-        self.assert_(v.parent_volume is v)
+        assert v.parent_volume is v
     
     def test_from_directory(self):
         root = Root(threaded=False)
         v = root.new_directory('foo')
         d = v.new_directory('foo')
-        self.assert_(d.parent_volume is v)
+        assert d.parent_volume is v
     
     def test_from_file(self):
         root = Root(threaded=False)
         v = root.new_directory('foo')
         d = v.new_directory('foo')
         f = d.new_file('foo')
-        self.assert_(f.parent_volume is v)
+        assert f.parent_volume is v
     
 
-class TCbuffer_path(TestCase):
+class Testbuffer_path:
     def test_initial_value(self):
         root = Root(threaded=False)
-        self.assertEqual(Path(()),root.buffer_path)
+        eq_(Path(()),root.buffer_path)
     
     def test_cdrom_volume_path(self):
         root = Root(threaded=False)
         v = root.new_directory('foo')
         root.buffer_path = Path('buffer')
         v.vol_type = VOLTYPE_CDROM
-        self.assertEqual(Path(('buffer','foo')),v.physical_path)
+        eq_(Path(('buffer','foo')),v.physical_path)
     
 
-class TCvolume_path_mode(TestCase):
-    def setUp(self):
+class Testvolume_path_mode:
+    def setup_method(self, method):
         self.root = Root(threaded=False)
         self.v = self.root.new_directory('vol')
         self.v.initial_path = Path('initial')
     
     def test_mode_normal(self):
         self.v.mode = MODE_NORMAL
-        self.assertEqual(('','vol','file'),self.f.path)
+        eq_(('','vol','file'),self.f.path)
     
     def test_mode_physical(self):
         self.v.mode = MODE_PHYSICAL
-        self.assertEqual(('initial','file'),self.f.path)
+        eq_(('initial','file'),self.f.path)
     
     def test_mode_token(self):
         self.v.mode = MODE_TOKEN
-        self.assertEqual(('!vol','file'),self.f.path)
+        eq_(('!vol','file'),self.f.path)
     
     def test_default(self):
-        self.assertEqual(MODE_NORMAL,self.v.mode)
+        eq_(MODE_NORMAL,self.v.mode)
     
     def test_invalidate_path(self):
         self.f.path
         self.v.mode = MODE_PHYSICAL
-        self.assertEqual(('initial','file'),self.f.path)
+        eq_(('initial','file'),self.f.path)
     
 
-class TCFileAttrs(TestCase):
+class TestFileAttrs:
     def test_has_music_attrs(self):
-        ref_dir = self.filepath('ogg')
+        ref_dir = testdata.filepath('ogg')
         ref = music.Directory(None,ref_dir)
         root = Root(threaded=False)
         v = root.add_volume(ref,'foo',VOLTYPE_FIXED)
         f = v['test1.ogg']
-        self.assertEqual('Astro',f.title)
+        eq_('Astro',f.title)
     
 
-class TCvolume_is_available(TestCase):
-    def setUp(self):
+class Testvolume_is_available:
+    def setup_method(self, method):
         self.root = Root(threaded=False)
         self.v = self.root.new_directory('vol')
     
     def test_true(self):
-        self.v.initial_path = self.filepath('') #it always exists
-        self.assertTrue(self.v.is_available)
+        self.v.initial_path = testdata.filepath('') #it always exists
+        assert self.v.is_available
     
     def test_false(self):
         self.v.initial_path = Path('/does/not/exist')
-        self.assertFalse(self.v.is_available)
+        assert not self.v.is_available
     
-    def test_removable(self):
+    def test_removable(self, tmpdir):
         # if the volume is removable, is_available is true when the disc is in place
         self.v.vol_type = VOLTYPE_CDROM
-        rootpath = self.tmpdir()
+        rootpath = str(tmpdir)
         self.root.buffer_path = Path(rootpath)
         # create a directory with self.v.name as a name to emulate the insertion of the CD in /Volumes
         os.mkdir(op.join(rootpath, self.v.name))
         self.v.initial_path = Path('/does/not/exist') # physical_path should be read
-        self.assertTrue(self.v.is_available)
+        assert self.v.is_available
     

core/sqlfs/sql_test.py

 import time
 import weakref
 
+from pytest import raises
 from hscommon.testutil import eq_
 
 import hsfs as fs
 from .. import manualfs
 from jobprogress.job import Job, JobCancelled
 
-from ..testcase import TestCase
 from ._sql import *
 
 INFO_SAMPLE = {
     f3 = d2.new_file('file3')
     return ref
 
-class TCDirectory(TestCase):
+class TestDirectory:
     def test_new_directory(self):
         root = Root(threaded=False)
         d = root.new_directory('bar')
-        self.assertEqual('bar',d.name)
-        self.assert_(root is d.parent)
-        self.assert_(d in root)
-        self.assert_(root[0] is d)
-        self.assert_(root.dirs[0] is d)
+        eq_('bar',d.name)
+        assert root is d.parent
+        assert d in root
+        assert root[0] is d
+        assert root.dirs[0] is d
     
-    def test_persistence(self):
-        p = self.tmpdir()
+    def test_persistence(self, tmpdir):
+        p = str(tmpdir)
         dbpath = op.join(p,'fs.db')
         root = Root(dbpath, 'root', threaded=False)
         root.new_directory('bar')
         root.con.close()
         root = Root(dbpath, 'root', threaded=False)
-        self.assertEqual('bar',root[0].name)
+        eq_('bar',root[0].name)
     
     def test_two_subdir_levels(self):
         root = Root(threaded=False)
         d1 = root.new_directory('foo')
         d2 = d1.new_directory('bar')
-        self.assert_(root[0][0] is d2)
-        self.assertEqual('bar',d2.name)
+        assert root[0][0] is d2
+        eq_('bar',d2.name)
     
     def test_escaping(self):
         root = Root(threaded=False)
         try:
             d1 = root.new_directory('foo\'bar')
-            self.assertEqual('foo\'bar',d1.name)
+            eq_('foo\'bar',d1.name)
         except sqlite.OperationalError:
             self.fail()
     
         d = root.new_directory('subdir')
         root.new_file('foo')
         file = d.new_file('bar')
-        self.assertEqual('foo',root.files[0].name)
-        self.assertEqual('bar',root.dirs[0].files[0].name)
-        self.assert_(isinstance(file,File))
+        eq_('foo',root.files[0].name)
+        eq_('bar',root.dirs[0].files[0].name)
+        assert isinstance(file,File)
     
     def test_name_collisions(self):
         root = Root(threaded=False)
         root.new_directory('foo')
-        self.assertRaises(fs.AlreadyExistsError,root.new_directory,'foo')
-        self.assertRaises(fs.AlreadyExistsError,root.new_file,'foo')
+        with raises(fs.AlreadyExistsError):
+            root.new_directory('foo')
+        with raises(fs.AlreadyExistsError):
+            root.new_file('foo')
     
     def test_unicode(self):
         root = Root(threaded=False)
         d = root.new_directory('foo\u00e9')
-        self.assertEqual('foo\u00e9',d.name)
+        eq_('foo\u00e9',d.name)
     
 
-class TCFile(TestCase):
+class TestFile:
     def test_escaping(self):
         root = Root(threaded=False)
         try:
             f = root.new_file('foo\'bar')
-            self.assertEqual('foo\'bar',f.name)
+            eq_('foo\'bar',f.name)
         except sqlite.OperationalError:
             self.fail()
     
 
-class TCAttr_multiple(TestCase):
+class TestAttr_multiple:
     def test_attrs(self):
         root = Root(threaded=False)
         f = root.new_file('foobar')
         f._set_attrs(INFO_SAMPLE)
         result = f._get_attrs()
-        self.assertEqual(INFO_SAMPLE, dict(result))
+        eq_(INFO_SAMPLE, dict(result))
     
-    def test_attrs_persistence(self):
-        p = self.tmpdir()
+    def test_attrs_persistence(self, tmpdir):
+        p = str(tmpdir)
         dbpath = op.join(p,'fs.db')
         root = Root(dbpath, threaded=False)
         f = root.new_file('foobar')
         root = Root(dbpath, threaded=False)
         f = root[0]
         result = f._get_attrs()
-        self.assertEqual(INFO_SAMPLE, dict(result))
+        eq_(INFO_SAMPLE, dict(result))
     
     def test_set_attrs_twice(self):
         root = Root(threaded=False)
         f._set_attrs(INFO_SAMPLE)
         sql = "select count(*) from attrs"
         result = f.con.execute(sql)
-        self.assertEqual(len(INFO_SAMPLE), result.fetchall()[0][0])
+        eq_(len(INFO_SAMPLE), result.fetchall()[0][0])
     
     def test_dir_attrs(self):
         #This test is just to verify that the _get_attrs _set_attrs func are at the Node level.
         subdir = root.new_directory('foobar')
         subdir._set_attrs(INFO_SAMPLE)
         result = subdir._get_attrs()
-        self.assertEqual(INFO_SAMPLE, dict(result))
+        eq_(INFO_SAMPLE, dict(result))
     
     def test_escaping(self):
         #Hey, this test nver failed because of my use of 'cur.executemany'
             self.fail()
     
 
-class TCAttr_single(TestCase):
+class TestAttr_single: