One thing that surprisingly many people don't know is that pytest can run unittest suites out of the box, without any modifications.
For example:
class Test(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.temp_dir = Path(tempfile.mkdtemp())
cls.filepath = cls.temp_dir / "data.csv"
cls.filepath.write_text(DATA.strip())
@classmethod
def tearDownClass(cls):
shutil.rmtree(cls.temp_dir)
def setUp(self):
self.grids = list(iter_grids_from_csv(self.filepath))
def test_read_properties(self):
self.assertEqual(self.grids[0], GridData("Main Grid", 48, 44))
self.assertEqual(self.grids[1], GridData("2nd Grid", 24, 21))
self.assertEqual(self.grids[2], GridData("3rd Grid", 24, 48))
def test_invalid_path(self):
with self.assertRaises...