Beispiel #1
0
 def test_name_from_path(self):
     test_module = support_file('scenario/tests_in_package/pkg1/test/test_things.py')
     test_package_path = support_file('scenario/tests_in_package')
     self.assertEqual(
         util.name_from_path(test_module),
         ('pkg1.test.test_things', test_package_path)
     )
Beispiel #2
0
 def test_name_from_path(self):
     test_module = support_file(
         "scenario/tests_in_package/pkg1/test/test_things.py")
     test_package_path = support_file("scenario/tests_in_package")
     self.assertEqual(
         util.name_from_path(test_module),
         ("pkg1.test.test_things", test_package_path),
     )
Beispiel #3
0
    def test_session_config_cacheing(self):
        """Test cacheing of config sections works"""

        # Create new session (generic one likely already cached
        # depending on test order)
        cache_sess = session.Session()
        cache_sess.loadConfigFiles(support_file("cfg", "a.cfg"))

        # First access to given section, should read from config file
        firstaccess = cache_sess.get("a")
        assert firstaccess.as_int("a") == 1

        # Hack cached Config object internals to make the stored value
        # something different
        cache_sess.configCache["a"]._mvd["a"] = "0"
        newitems = []
        for item in cache_sess.configCache["a"]._items:
            if item != ("a", "1"):
                newitems.append(item)
            else:
                newitems.append(("a", "0"))
        cache_sess.configCache["a"]._items = newitems

        # Second access to given section, confirm returns cached value
        # rather than parsing config file again
        secondaccess = cache_sess.get("a")
        assert secondaccess.as_int("a") == 0
Beispiel #4
0
    def test_session_config_cacheing(self):
        """Test cacheing of config sections works"""

        # Create new session (generic one likely already cached
        # depending on test order)
        cache_sess = session.Session()
        cache_sess.loadConfigFiles(support_file('cfg', 'a.cfg'))

        # First access to given section, should read from config file
        firstaccess = cache_sess.get('a')
        assert firstaccess.as_int("a") == 1

        # Hack cached Config object internals to make the stored value
        # something different
        cache_sess.configCache["a"]._mvd["a"] = "0"
        newitems = []
        for item in cache_sess.configCache["a"]._items:
            if item != ("a", "1"):
                newitems.append(item)
            else:
                newitems.append(("a", "0"))
        cache_sess.configCache["a"]._items = newitems

        # Second access to given section, confirm returns cached value
        # rather than parsing config file again
        secondaccess = cache_sess.get("a")
        assert secondaccess.as_int("a") == 0
Beispiel #5
0
    def test_module_name_with_start_dir(self):
        proc = self.runIn(
            '.', '-v', '-s', support_file('scenario/tests_in_package'),
            'pkg1.test.test_things')

        self.assertTestRunOutputMatches(proc, stderr='Ran 25 tests')
        self.assertEqual(proc.poll(), 1)
Beispiel #6
0
    def test_module_name_with_start_dir(self):
        proc = self.runIn(
            '.', '-v', '-s', support_file('scenario/tests_in_package'),
            'pkg1.test.test_things')

        self.assertTestRunOutputMatches(proc, stderr='Ran 25 tests')
        self.assertEqual(proc.poll(), 1)
Beispiel #7
0
    def test_dispatch_tests_receive_events(self):
        ssn = {
            'config': self.session.config,
            'verbosity': 1,
            'startDir': support_file('scenario/tests_in_package'),
            'topLevelDir': support_file('scenario/tests_in_package'),
            'logLevel': 100,
            'pluginClasses': [discovery.DiscoveryLoader,
                              testcases.TestCaseLoader,
                              buffer.OutputBufferPlugin]

        }
        conn = Conn(['pkg1.test.test_things.SomeTests.test_ok',
                     'pkg1.test.test_things.SomeTests.test_failed'])
        procserver(ssn, conn)

        # check conn calls
        expect = [('pkg1.test.test_things.SomeTests.test_ok',
                   [('startTest', {}),
                    ('setTestOutcome', {'outcome': 'passed'}),
                    ('testOutcome', {'outcome': 'passed'}),
                    ('stopTest', {})]
                   ),
                  ('pkg1.test.test_things.SomeTests.test_failed',
                   [('startTest', {}),
                    ('setTestOutcome', {
                     'outcome': 'failed',
                     'expected': False,
                     'metadata': {'stdout': 'Hello stdout\n'}}),
                    ('testOutcome', {
                     'outcome': 'failed',
                     'expected': False,
                     'metadata': {'stdout': 'Hello stdout\n'}}),
                    ('stopTest', {})]
                   ),
                  ]
        for val in conn.sent:
            if val is None:
                break
            test, events = val
            exp_test, exp_events = expect.pop(0)
            self.assertEqual(test, exp_test)
            for method, event in events:
                exp_meth, exp_attr = exp_events.pop(0)
                self.assertEqual(method, exp_meth)
                for attr, val in exp_attr.items():
                    self.assertEqual(getattr(event, attr), val)
Beispiel #8
0
    def test_dispatch_tests_receive_events(self):
        ssn = {
            'config': self.session.config,
            'verbosity': 1,
            'startDir': support_file('scenario/tests_in_package'),
            'topLevelDir': support_file('scenario/tests_in_package'),
            'logLevel': 100,
            'pluginClasses': [discovery.DiscoveryLoader,
                              testcases.TestCaseLoader,
                              buffer.OutputBufferPlugin]

        }
        conn = Conn(['pkg1.test.test_things.SomeTests.test_ok',
                     'pkg1.test.test_things.SomeTests.test_failed'])
        procserver(ssn, conn)

        # check conn calls
        expect = [('pkg1.test.test_things.SomeTests.test_ok',
                   [('startTest', {}),
                    ('setTestOutcome', {'outcome': 'passed'}),
                    ('testOutcome', {'outcome': 'passed'}),
                    ('stopTest', {})]
                   ),
                  ('pkg1.test.test_things.SomeTests.test_failed',
                   [('startTest', {}),
                    ('setTestOutcome', {
                     'outcome': 'failed',
                     'expected': False,
                     'metadata': {'stdout': 'Hello stdout\n'}}),
                    ('testOutcome', {
                     'outcome': 'failed',
                     'expected': False,
                     'metadata': {'stdout': 'Hello stdout\n'}}),
                    ('stopTest', {})]
                   ),
                  ]
        for val in conn.sent:
            if val is None:
                break
            test, events = val
            exp_test, exp_events = expect.pop(0)
            self.assertEqual(test, exp_test)
            for method, event in events:
                exp_meth, exp_attr = exp_events.pop(0)
                self.assertEqual(method, exp_meth)
                for attr, val in exp_attr.items():
                    self.assertEqual(getattr(event, attr), val)
Beispiel #9
0
 def test_discovery_supports_code_in_lib_dir(self):
     self.session.startDir = support_file('scenario/package_in_lib')
     event = events.LoadFromNamesEvent(self.loader, [], None)
     result = self.session.hooks.loadTestsFromNames(event)
     assert isinstance(result, self.loader.suiteClass)
     self.assertEqual(len(result._tests), 1)
     self.assertEqual(len(self.watcher.called), 1)
     self.assertEqual(self.watcher.called[0].module.__name__, 'tests')
 def test_discovery_supports_code_in_lib_dir(self):
     self.session.startDir = support_file("scenario/package_in_lib")
     event = events.LoadFromNamesEvent(self.loader, [], None)
     result = self.session.hooks.loadTestsFromNames(event)
     assert isinstance(result, self.loader.suiteClass)
     self.assertEqual(len(result._tests), 1)
     self.assertEqual(len(self.watcher.called), 1)
     self.assertEqual(self.watcher.called[0].module.__name__, "tests")
Beispiel #11
0
 def test_start_directory_inside_package(self):
     proc = self.runIn(
         'scenario/tests_in_package/pkg1/test',
         '-v',
         '-t',
         support_file('scenario/tests_in_package'))
     self.assertTestRunOutputMatches(proc, stderr='Ran 25 tests')
     self.assertEqual(proc.poll(), 1)
Beispiel #12
0
 def test_can_discover_test_modules_in_packages(self):
     self.session.startDir = support_file('scenario/tests_in_package')
     event = events.LoadFromNamesEvent(self.loader, [], None)
     result = self.session.hooks.loadTestsFromNames(event)
     assert isinstance(result, self.loader.suiteClass)
     self.assertEqual(len(result._tests), 1)
     self.assertEqual(len(self.watcher.called), 1)
     self.assertEqual(self.watcher.called[0].module.__name__,
                      'pkg1.test.test_things')
Beispiel #13
0
 def test_start_directory_inside_package(self):
     proc = self.runIn(
         "scenario/tests_in_package/pkg1/test",
         "-v",
         "-t",
         support_file("scenario/tests_in_package"),
     )
     self.assertTestRunOutputMatches(proc, stderr="Ran 25 tests")
     self.assertEqual(proc.poll(), 1)
Beispiel #14
0
 def run_with_junitxml_loaded(self, scenario, *args):
     work_dir = os.getcwd()
     test_dir = support_file(*scenario)
     junit_report = os.path.join(work_dir, 'nose2-junit.xml')
     if os.path.exists(junit_report):
         os.remove(junit_report)
     proc = self.runIn(work_dir, '-s%s' % test_dir,
                       '--plugin=nose2.plugins.junitxml', '-v', *args)
     return junit_report, proc
 def test_can_discover_test_modules_in_packages(self):
     self.session.startDir = support_file('scenario/tests_in_package')
     event = events.LoadFromNamesEvent(self.loader, [], None)
     result = self.session.hooks.loadTestsFromNames(event)
     assert isinstance(result, self.loader.suiteClass)
     self.assertEqual(len(result._tests), 1)
     self.assertEqual(len(self.watcher.called), 1)
     self.assertEqual(self.watcher.called[0].module.__name__,
                      'pkg1.test.test_things')
Beispiel #16
0
    def test_flatten_respects_module_fixtures(self):
        sys.path.append(support_file('scenario/module_fixtures'))
        import test_mf_testcase as mod

        suite = unittest.TestSuite()
        suite.addTest(mod.Test('test_1'))
        suite.addTest(mod.Test('test_2'))

        flat = list(self.plugin._flatten(suite))
        self.assertEqual(flat, ['test_mf_testcase'])
Beispiel #17
0
    def test_flatten_respects_module_fixtures(self):
        sys.path.append(support_file('scenario/module_fixtures'))
        import test_mf_testcase as mod

        suite = unittest.TestSuite()
        suite.addTest(mod.Test('test_1'))
        suite.addTest(mod.Test('test_2'))

        flat = list(self.plugin._flatten(suite))
        self.assertEqual(flat, ['test_mf_testcase'])
Beispiel #18
0
    def test_module_name_with_start_dir(self):
        proc = self.runIn(
            ".",
            "-v",
            "-s",
            support_file("scenario/tests_in_package"),
            "pkg1.test.test_things",
        )

        self.assertTestRunOutputMatches(proc, stderr="Ran 25 tests")
        self.assertEqual(proc.poll(), 1)
Beispiel #19
0
    def run_with_junitxml_loaded(self, scenario, *args):
        work_dir = os.getcwd()
        test_dir = support_file(*scenario)
        junit_report = os.path.join(work_dir, 'nose2-junit.xml')

        proc = self.runIn(work_dir,
                          '-s%s' % test_dir,
                          '--plugin=nose2.plugins.junitxml',
                          '-v',
                          *args)
        return junit_report, proc
Beispiel #20
0
    def test_flatten_without_fixtures(self):
        sys.path.append(support_file('scenario/slow'))
        import test_slow as mod

        suite = unittest.TestSuite()
        suite.addTest(mod.TestSlow('test_ok'))
        suite.addTest(mod.TestSlow('test_fail'))
        suite.addTest(mod.TestSlow('test_err'))

        flat = list(self.plugin._flatten(suite))
        self.assertEqual(len(flat), 3)
Beispiel #21
0
    def test_flatten_without_fixtures(self):
        sys.path.append(support_file('scenario/slow'))
        import test_slow as mod

        suite = unittest.TestSuite()
        suite.addTest(mod.TestSlow('test_ok'))
        suite.addTest(mod.TestSlow('test_fail'))
        suite.addTest(mod.TestSlow('test_err'))

        flat = list(self.plugin._flatten(suite))
        self.assertEqual(len(flat), 3)
Beispiel #22
0
    def test_run(self):
        # ensure there is no .coverage file at the start of test
        reportfile = support_file("scenario/test_with_module/.coverage")
        try:
            os.remove(reportfile)
        except OSError:
            pass

        proc = self.runIn("scenario/test_with_module", "-v", "--with-coverage",
                          "--coverage=lib/")
        self.assertProcOutputPattern(proc, "lib", r"\s+8\s+5\s+38%")
        self.assertTrue(os.path.exists(reportfile))
Beispiel #23
0
    def test_run(self):
        # ensure there is no .coverage file at the start of test
        reportfile = support_file('scenario/test_with_module/.coverage')
        try:
            os.remove(reportfile)
        except OSError:
            pass

        proc = self.runIn('scenario/test_with_module', '-v', '--with-coverage',
                          '--coverage=lib/')
        self.assertProcOutputPattern(proc, 'lib', '\s+8\s+5\s+38%')
        self.assertTrue(os.path.exists(reportfile))
Beispiel #24
0
 def test_match_path_event_can_prevent_discovery(self):
     class NoTestsForYou(events.Plugin):
         def matchPath(self, event):
             event.handled = True
             return False
     mp = NoTestsForYou(session=self.session)
     mp.register()
     self.session.startDir = support_file('scenario/tests_in_package')
     event = events.LoadFromNamesEvent(self.loader, [], None)
     result = self.session.hooks.loadTestsFromNames(event)
     assert isinstance(result, self.loader.suiteClass)
     self.assertEqual(len(result._tests), 0)
     self.assertEqual(len(self.watcher.called), 0)
Beispiel #25
0
 def run_with_junitxml_loaded(self, scenario, *args):
     work_dir = os.getcwd()
     test_dir = support_file(*scenario)
     junit_report = os.path.join(work_dir, 'nose2-junit.xml')
     config = os.path.join(test_dir, 'unittest.cfg')
     config_args = ()
     if os.path.exists(junit_report):
         os.remove(junit_report)
     if os.path.exists(config):
         config_args = ('-c', config)
     proc = self.runIn(work_dir, '-s%s' % test_dir,
                       '--plugin=nose2.plugins.junitxml', '-v',
                       *(config_args + args))
     return junit_report, proc
Beispiel #26
0
    def test_flatten_nested_suites(self):
        sys.path.append(support_file("scenario/slow"))
        import test_slow as mod

        suite = unittest.TestSuite()
        suite.addTest(mod.TestSlow("test_ok"))
        suite.addTest(mod.TestSlow("test_fail"))
        suite.addTest(mod.TestSlow("test_err"))

        suite2 = unittest.TestSuite()
        suite2.addTest(suite)

        flat = list(self.plugin._flatten(suite2))
        self.assertEqual(len(flat), 3)
Beispiel #27
0
 def run_with_junitxml_loaded(self, scenario, *args, **kwargs):
     work_dir = os.getcwd()
     test_dir = support_file(*scenario)
     junit_report = os.path.join(
         work_dir, kwargs.get("junit_report", "nose2-junit.xml"))
     config = os.path.join(test_dir, "unittest.cfg")
     config_args = ()
     if os.path.exists(junit_report):
         os.remove(junit_report)
     if os.path.exists(config):
         config_args = ("-c", config)
     proc = self.runIn(work_dir, "-s%s" % test_dir,
                       "--plugin=nose2.plugins.junitxml", "-v",
                       *(config_args + args))
     return junit_report, proc
Beispiel #28
0
 def test_handle_file_event_can_add_tests(self):
     class TextTest(TestCase):
         def test(self):
             pass
     class TestsInText(events.Plugin):
         def handleFile(self, event):
             if event.path.endswith('.txt'):
                 event.extraTests.append(TextTest('test'))
     mp = TestsInText(session=self.session)
     mp.register()
     self.session.startDir = support_file('scenario/tests_in_package')
     event = events.LoadFromNamesEvent(self.loader, [], None)
     result = self.session.hooks.loadTestsFromNames(event)
     assert isinstance(result, self.loader.suiteClass)
     self.assertEqual(len(result._tests), 2)
     self.assertEqual(len(self.watcher.called), 1)
 def run_with_junitxml_loaded(self, scenario, *args):
     work_dir = os.getcwd()
     test_dir = support_file(*scenario)
     junit_report = os.path.join(work_dir, 'nose2-junit.xml')
     config = os.path.join(test_dir, 'unittest.cfg')
     config_args = ()
     if os.path.exists(junit_report):
         os.remove(junit_report)
     if os.path.exists(config):
         config_args = ('-c', config)
     proc = self.runIn(work_dir,
                       '-s%s' % test_dir,
                       '--plugin=nose2.plugins.junitxml',
                       '-v',
                       *(config_args + args))
     return junit_report, proc
Beispiel #30
0
    def test_run(self):
        # ensure there is no .coverage file at the start of test
        reportfile = support_file('scenario/test_with_module/.coverage')
        try:
            os.remove(reportfile)
        except OSError:
            pass

        proc = self.runIn(
            'scenario/test_with_module',
            '-v',
            '--with-coverage',
            '--coverage=lib/'
        )
        self.assertProcOutputPattern(proc, 'lib', '\s+8\s+5\s+38%')
        self.assertTrue(os.path.exists(reportfile))
Beispiel #31
0
    def test_flatten_respects_class_fixtures(self):
        sys.path.append(support_file('scenario/class_fixtures'))
        import test_cf_testcase as mod

        suite = unittest.TestSuite()
        suite.addTest(mod.Test('test_1'))
        suite.addTest(mod.Test('test_2'))
        suite.addTest(mod.Test2('test_1'))
        suite.addTest(mod.Test2('test_2'))
        suite.addTest(mod.Test3('test_3'))

        flat = list(self.plugin._flatten(suite))
        self.assertEqual(flat, ['test_cf_testcase.Test2.test_1',
                                'test_cf_testcase.Test2.test_2',
                                'test_cf_testcase.Test',
                                'test_cf_testcase.Test3',
                                ])
Beispiel #32
0
 def test_start_directory_inside_package(self):
     proc = self.runIn(
         "scenario/doctests/doctests_pkg1",
         "-v",
         "--plugin=nose2.plugins.doctests",
         "--with-doctest",
         "-t",
         support_file("scenario/doctests"),
     )
     self.assertTestRunOutputMatches(proc, stderr="Ran 3 tests")
     self.assertTestRunOutputMatches(
         proc, stderr="Doctest: doctests_pkg1.docs1 ... ok")
     self.assertTestRunOutputMatches(proc,
                                     stderr="Doctest: docs1.rst ... ok")
     self.assertTestRunOutputMatches(proc,
                                     stderr="Doctest: docs1.txt ... ok")
     self.assertEqual(proc.poll(), 0)
Beispiel #33
0
    def test_flatten_respects_class_fixtures(self):
        sys.path.append(support_file('scenario/class_fixtures'))
        import test_cf_testcase as mod

        suite = unittest.TestSuite()
        suite.addTest(mod.Test('test_1'))
        suite.addTest(mod.Test('test_2'))
        suite.addTest(mod.Test2('test_1'))
        suite.addTest(mod.Test2('test_2'))
        suite.addTest(mod.Test3('test_3'))

        flat = list(self.plugin._flatten(suite))
        self.assertEqual(flat, ['test_cf_testcase.Test2.test_1',
                                'test_cf_testcase.Test2.test_2',
                                'test_cf_testcase.Test',
                                'test_cf_testcase.Test3',
                                ])
 def test_start_directory_inside_package(self):
     proc = self.runIn(
         'scenario/doctests/doctests_pkg1',
         '-v',
         '--plugin=nose2.plugins.doctests',
         '--with-doctest',
         '-t',
         support_file('scenario/doctests')
     )
     self.assertTestRunOutputMatches(proc, stderr='Ran 3 tests')
     self.assertTestRunOutputMatches(
         proc, stderr='Doctest: doctests_pkg1.docs1 ... ok')
     self.assertTestRunOutputMatches(
         proc, stderr='Doctest: docs1.rst ... ok')
     self.assertTestRunOutputMatches(
         proc, stderr='Doctest: docs1.txt ... ok')
     self.assertEqual(proc.poll(), 0)
Beispiel #35
0
    def test_flatten_respects_class_fixtures(self):
        sys.path.append(support_file("scenario/class_fixtures"))
        import test_cf_testcase as mod

        suite = unittest.TestSuite()
        suite.addTest(mod.Test("test_1"))
        suite.addTest(mod.Test("test_2"))
        suite.addTest(mod.Test2("test_1"))
        suite.addTest(mod.Test2("test_2"))
        suite.addTest(mod.Test3("test_3"))

        flat = list(self.plugin._flatten(suite))
        self.assertEqual(
            flat,
            [
                "test_cf_testcase.Test2.test_1",
                "test_cf_testcase.Test2.test_2",
                "test_cf_testcase.Test",
                "test_cf_testcase.Test3",
            ],
        )
Beispiel #36
0
 def setUp(self):
     self.s = session.Session()
     self.s.loadConfigFiles(support_file('cfg', 'a.cfg'),
                            support_file('cfg', 'b.cfg'))
     sys.path.insert(0, support_file('lib'))
Beispiel #37
0
 def setUp(self):
     self.s = session.Session()
     self.s.loadConfigFiles(support_file("cfg", "a.cfg"), support_file("cfg", "b.cfg"))
     sys.path.insert(0, support_file("lib"))
 def setUp(self):
     for m in [m for m in sys.modules if m.startswith('pkgegg')]:
         del sys.modules[m]
     self.egg_path = support_file('scenario/tests_in_unzipped_eggs/pkgunegg-0.0.0-py2.7.egg')
     sys.path.append(self.egg_path)
Beispiel #39
0
 def test_name_from_path(self):
     self.assertEqual(
         util.name_from_path(
             support_file(
                 'scenario/tests_in_package/pkg1/test/test_things.py')),
         'pkg1.test.test_things')
Beispiel #40
0
    def test_dispatch_tests_receive_events(self):
        ssn = {
            "config":
            self.session.config,
            "verbosity":
            1,
            "startDir":
            support_file("scenario/tests_in_package"),
            "topLevelDir":
            support_file("scenario/tests_in_package"),
            "logLevel":
            100,
            "pluginClasses": [
                discovery.DiscoveryLoader,
                testcases.TestCaseLoader,
                buffer.OutputBufferPlugin,
            ],
        }
        conn = Conn([
            "pkg1.test.test_things.SomeTests.test_ok",
            "pkg1.test.test_things.SomeTests.test_failed",
        ])
        procserver(ssn, conn)

        # check conn calls
        expect = [
            (
                "pkg1.test.test_things.SomeTests.test_ok",
                [
                    ("startTest", {}),
                    ("setTestOutcome", {
                        "outcome": "passed"
                    }),
                    ("testOutcome", {
                        "outcome": "passed"
                    }),
                    ("stopTest", {}),
                ],
            ),
            (
                "pkg1.test.test_things.SomeTests.test_failed",
                [
                    ("startTest", {}),
                    (
                        "setTestOutcome",
                        {
                            "outcome": "failed",
                            "expected": False,
                            "metadata": {
                                "stdout":
                                """\
-------------------- >> begin captured stdout << ---------------------
Hello stdout

--------------------- >> end captured stdout << ----------------------"""
                            },
                        },
                    ),
                    (
                        "testOutcome",
                        {
                            "outcome": "failed",
                            "expected": False,
                            "metadata": {
                                "stdout":
                                """\
-------------------- >> begin captured stdout << ---------------------
Hello stdout

--------------------- >> end captured stdout << ----------------------"""
                            },
                        },
                    ),
                    ("stopTest", {}),
                ],
            ),
        ]
        for val in conn.sent:
            if val is None:
                break
            test, events = val
            exp_test, exp_events = expect.pop(0)
            self.assertEqual(test, exp_test)
            for method, event in events:
                exp_meth, exp_attr = exp_events.pop(0)
                self.assertEqual(method, exp_meth)
                for attr, val in exp_attr.items():
                    self.assertEqual(getattr(event, attr), val)
Beispiel #41
0
 def test_name_from_path(self):
     self.assertEqual(
         util.name_from_path(support_file('scenario/tests_in_package/pkg1/test/test_things.py')), 'pkg1.test.test_things')
Beispiel #42
0
 def setUp(self):
     self.s = session.Session()
     self.s.loadConfigFiles(support_file('cfg', 'a.cfg'),
                            support_file('cfg', 'b.cfg'))
     sys.path.insert(0, support_file('lib'))
Beispiel #43
0
 def test_module_name_with_start_dir(self):
     proc = self.runIn(
         '.', '-v', '-s', support_file('scenario/package_in_lib'), 'tests')
     self.assertTestRunOutputMatches(proc, stderr='Ran 3 tests')
     self.assertEqual(proc.poll(), 1)
Beispiel #44
0
 def test_module_name_with_start_dir(self):
     proc = self.runIn(
         '.', '-v', '-s', support_file('scenario/package_in_lib'), 'tests')
     self.assertTestRunOutputMatches(proc, stderr='Ran 3 tests')
     self.assertEqual(proc.poll(), 1)
Beispiel #45
0
 def setUp(self):
     for m in [m for m in sys.modules if m.startswith("pkgegg")]:
         del sys.modules[m]
     self.egg_path = support_file(
         "scenario/tests_in_unzipped_eggs/pkgunegg-0.0.0-py2.7.egg")
     sys.path.append(self.egg_path)
Beispiel #46
0
 def test_name_from_path(self):
     test_module = support_file(
         'scenario/tests_in_package/pkg1/test/test_things.py')
     test_package_path = support_file('scenario/tests_in_package')
     self.assertEqual(util.name_from_path(test_module),
                      ('pkg1.test.test_things', test_package_path))
Beispiel #47
0
 def setUp(self):
     self.s = session.Session()
     self.s.loadConfigFiles(support_file("cfg", "a.cfg"),
                            support_file("cfg", "b.cfg"))
     sys.path.insert(0, support_file("lib"))