コード例 #1
0
 def test_checks_requires(self):
     dist = Distribution()
     cmd = test(dist)
     phony_project = 'ohno_ohno-impossible_1234-name_stop-that!'
     cmd.tests_require = [phony_project]
     cmd.ensure_finalized()
     logs = self.get_logs()
     self.assertIn(phony_project, logs[-1])
コード例 #2
0
 def test_checks_requires(self):
     dist = Distribution()
     cmd = test(dist)
     phony_project = 'ohno_ohno-impossible_1234-name_stop-that!'
     cmd.tests_require = [phony_project]
     cmd.ensure_finalized()
     logs = self.get_logs()
     self.assertIn(phony_project, logs[-1])
コード例 #3
0
ファイル: test_test.py プロジェクト: irslambouf/SyncServer
 def test_calls_discover(self):
     self.safely_replace(ut1.TestLoader, "discover", delete=True)
     mock_ut2 = self.prepare_mock_ut2()
     record = []
     mock_ut2.TestLoader.discover = lambda self, path: record.append(path)
     dist = Distribution()
     cmd = test(dist)
     cmd.run()
     self.assertEqual(record, [os.curdir])
コード例 #4
0
ファイル: test_test.py プロジェクト: irslambouf/SyncServer
    def test_gets_unittest_discovery(self):
        mock_ut2 = self.prepare_mock_ut2()
        dist = Distribution()
        cmd = test(dist)
        self.safely_replace(ut1.TestLoader, "discover", lambda: None)
        self.assertEqual(cmd.get_ut_with_discovery(), ut1)

        del ut1.TestLoader.discover
        self.assertEqual(cmd.get_ut_with_discovery(), mock_ut2)
コード例 #5
0
ファイル: test_test.py プロジェクト: irslambouf/SyncServer
    def test_custom_runner(self):
        dist = Distribution()
        cmd = test(dist)

        record = []
        cmd.runner = self.prepare_named_function(lambda: record.append("runner called"))
        cmd.ensure_finalized()
        cmd.run()
        self.assertEqual(["runner called"], record)
コード例 #6
0
 def test_calls_discover(self):
     self.safely_replace(ut1.TestLoader, "discover", delete=True)
     mock_ut2 = self.prepare_mock_ut2()
     record = []
     mock_ut2.TestLoader.discover = lambda self, path: record.append(path)
     dist = Distribution()
     cmd = test(dist)
     cmd.run()
     self.assertEqual([os.curdir], record)
コード例 #7
0
    def test_gets_unittest_discovery(self):
        mock_ut2 = self.prepare_mock_ut2()
        dist = Distribution()
        cmd = test(dist)
        self.safely_replace(ut1.TestLoader, "discover", lambda: None)
        self.assertEqual(cmd.get_ut_with_discovery(), ut1)

        del ut1.TestLoader.discover
        self.assertEqual(cmd.get_ut_with_discovery(), mock_ut2)
コード例 #8
0
 def test_custom_runner(self):
     dist = Distribution()
     cmd = test(dist)
     record = []
     cmd.runner = self.prepare_named_function(
         lambda: record.append("runner called"))
     cmd.ensure_finalized()
     cmd.run()
     self.assertEqual(["runner called"], record)
コード例 #9
0
ファイル: test_test.py プロジェクト: irslambouf/SyncServer
 def test_checks_requires(self):
     dist = Distribution()
     cmd = test(dist)
     phony_project = 'ohno_ohno-impossible_1234-name_stop-that!'
     cmd.tests_require = [phony_project]
     record = []
     cmd.announce = lambda *args: record.append(args)
     cmd.ensure_finalized()
     self.assertEqual(1, len(record))
     self.assertIn(phony_project, record[0][0])
コード例 #10
0
    def test_builds_before_running_tests(self):
        self.addCleanup(set_command, 'distutils2.command.build.build')
        set_command('distutils2.tests.test_command_test.MockBuildCmd')

        dist = Distribution()
        dist.get_command_obj('build')._record = record = []
        cmd = test(dist)
        cmd.runner = self.prepare_named_function(lambda: None)
        cmd.ensure_finalized()
        cmd.run()
        self.assertEqual(['build has run'], record)
コード例 #11
0
    def test_builds_before_running_tests(self):
        self.addCleanup(set_command, 'distutils2.command.build.build')
        set_command('distutils2.tests.test_command_test.MockBuildCmd')

        dist = Distribution()
        dist.get_command_obj('build')._record = record = []
        cmd = test(dist)
        cmd.runner = self.prepare_named_function(lambda: None)
        cmd.ensure_finalized()
        cmd.run()
        self.assertEqual(['build has run'], record)
コード例 #12
0
ファイル: test_test.py プロジェクト: irslambouf/SyncServer
    def test_builds_before_running_tests(self):
        dist = Distribution()
        cmd = test(dist)
        cmd.runner = self.prepare_named_function(lambda: None)
        record = []
        class MockBuildCmd(Command):
            build_lib = "mock build lib"
            def initialize_options(self): pass
            def finalize_options(self): pass
            def run(self): record.append("build run")
        dist.cmdclass['build'] = MockBuildCmd

        cmd.ensure_finalized()
        cmd.run()
        self.assertEqual(record, ['build run'])
コード例 #13
0
ファイル: test_test.py プロジェクト: irslambouf/SyncServer
    def test_runs_unittest(self):
        module_name, a_module = self.prepare_a_module()
        record = []
        a_module.recorder = lambda *args: record.append("suite")

        class MockTextTestRunner(object):
            def __init__(*_, **__): pass
            def run(_self, suite):
                record.append("run")
        self.safely_replace(ut1, "TextTestRunner", MockTextTestRunner)

        dist = Distribution()
        cmd = test(dist)
        cmd.suite = "%s.recorder" % module_name
        cmd.run()
        self.assertEqual(record, ["suite", "run"])
コード例 #14
0
    def test_runs_unittest(self):
        module_name, a_module = self.prepare_a_module()
        record = []
        a_module.recorder = lambda *args: record.append("suite")

        class MockTextTestRunner:
            def __init__(*_, **__):
                pass

            def run(_self, suite):
                record.append("run")

        self.safely_replace(ut1, "TextTestRunner", MockTextTestRunner)

        dist = Distribution()
        cmd = test(dist)
        cmd.suite = "%s.recorder" % module_name
        cmd.run()
        self.assertEqual(record, ["suite", "run"])