self.assertEqual(dev_han.status, FileHandleStatus.Closed) self.assertEqual(count_open_files(), 0) fd_open = dev_han.open() self.assertEqual(dev_han.status, FileHandleStatus.Opened) fd_open.write("Foo") self.assertEqual(count_open_files(), 1) dev_han = None fd_open.write("Foo") def test_delete_handle(self): dev_han = FileHandleCM(TEST_FILE, {"mode": "w"}) self.assertEqual(dev_han.status, FileHandleStatus.Closed) self.assertEqual(count_open_files(), 0) fd_open = dev_han.open() self.assertEqual(dev_han.status, FileHandleStatus.Opened) fd_open.write("Foo") self.assertEqual(count_open_files(), 1) del dev_han fd_open.write("Foo") def tearDown(self): self.assertEqual(count_open_files(), 0) if __name__ == "__main__": run_tests()
def test_1(self): routes = tuple(map(list, select(self.rules[0], self.data))) expected = ([], [5], [8], [9, 10], [50], [-3]) self.assertTupleEqual(routes, expected) def test_2(self): routes = tuple(map(list, select(self.rules[1], self.data))) expected = ([5], [5, 8], [50, 10], [50], [9, -3]) self.assertTupleEqual(routes, expected) def test_3(self): routes = select(None, self.data) self.assertListEqual(list(routes[0]), self.data) self.assertListEqual(list(routes[1]), []) def test_4(self): routes = tuple(map(list, select(self.rules[0], self.data, strict=True))) expected = ([], [5], [8], [9, 10], [50], [-3]) self.assertTupleEqual(routes, expected) def test_5(self): routes = tuple(map(list, select(self.rules[1], self.data, strict=True))) expected = ([5], [8], [50, 10], [], [9, -3]) self.assertTupleEqual(routes, expected) if __name__ == '__main__': run_tests(verbosity=2)
from unittest import TestCase from unittest import main as run_tests from mq import * class TestMe(TestCase): def test_can_subscribe_to_queue(self): message = "hi!" self.message_recieved = None def callback(message): self.message_recieved = message sub = Subscriptions() queue = InMemoryQueue("My Queue") sub.add_queue(queue) sub.subscribe("My Queue", callback) queue.post(message) self.assertEqual(self.message_recieved, message) if __name__ == "__main__": run_tests()
DRIVER_MANAGER = webdrivermanager.IEDriverManager @flaky def test_download(self): self.instance = self.DRIVER_MANAGER(download_root=self.temp_dir.name, os_name='win') filename = self.instance.download(show_progress_bar=False) self.assertTrue(isfile(filename), 'Downloading and saving seems to have failed') @flaky def test_download_and_install(self): link_path = self.make_link_dir() self.instance = self.DRIVER_MANAGER(download_root=self.temp_dir.name, link_path=link_path, os_name='win') driver_directory, driver_binary = self.instance.download_and_install( show_progress_bar=False) self.assertTrue(isfile(driver_binary), 'Downloading and saving seems to have failed') self.assertTrue(isfile(driver_directory), 'Downloading and saving seems to have failed') if __name__ == '__main__': with open('acceptance_tests.xml', 'wb') as output: run_tests(testRunner=XMLTestRunner(output=output), failfast=False, buffer=False, catchbreak=False)