Esempio n. 1
0
 def setUp(self):
     self.idfile = os.path.abspath(
         os.path.join(os.path.dirname(__file__), self.idfile_location))
     parser = optparse.OptionParser()
     argv = [
         # 0 is always program
         "lode_runner",
         "--failed",
         "--with-id",
         "--id-file=%s" % self.idfile
     ]
     self.x = TestId()
     self.x.add_options(parser, env={})
     (options, args) = parser.parse_args(argv)
     self.config = Config()
     self.x.configure(options, self.config)
     self.config.plugins = PluginManager()
     self.config.plugins.addPlugin(Dataprovider())
     self.config.plugins.addPlugin(TestId())
     self.config.configure(argv)
Esempio n. 2
0
class TestIdTest(unittest.TestCase):
    tests_location = "tests/data/testid/testid.py"
    idfile_location = "data/testid/.noseids"

    def setUp(self):
        self.idfile = os.path.abspath(
            os.path.join(os.path.dirname(__file__), self.idfile_location))
        parser = optparse.OptionParser()
        argv = [
            # 0 is always program
            "lode_runner",
            "--failed",
            "--with-id",
            "--id-file=%s" % self.idfile
        ]
        self.x = TestId()
        self.x.add_options(parser, env={})
        (options, args) = parser.parse_args(argv)
        self.config = Config()
        self.x.configure(options, self.config)
        self.config.plugins = PluginManager()
        self.config.plugins.addPlugin(Dataprovider())
        self.config.plugins.addPlugin(TestId())
        self.config.configure(argv)

    def tearDown(self):
        try:
            os.remove(self.idfile)
        except OSError:
            pass

    def test_load_tests_path_with_no_info_in_idfile(self):
        names = self.x.loadTestsFromNames([self.tests_location])
        self.assertEqual((None, [self.tests_location]), names)

    def test_loaded_names_with_failing_tests_in_idfile(self):
        stream = StringIO()

        tests = TestLoader(config=self.config).loadTestsFromName(
            self.tests_location)
        result = LodeTestResult(stream, None, 0)
        tests.run(result)
        # generate needed idfile
        self.config.plugins.finalize(result)

        names = self.x.loadTestsFromNames([self.tests_location])
        loaded_tests = [(parse_test_name(name)[1], parse_test_name(name)[2])
                        for name in names[1]]
        self.assertEqual(
            [('DataprovidedTestCase',
              'test_with_dataprovider_failing_on_everything_except_2_1'),
             ('DataprovidedTestCase',
              'test_with_dataprovider_failing_on_everything_except_2_3')],
            loaded_tests)
Esempio n. 3
0
 def setUp(self):
     self.idfile = os.path.abspath(
         os.path.join(os.path.dirname(__file__), self.idfile_location))
     parser = optparse.OptionParser()
     argv = [
         # 0 is always program
         "lode_runner",
         "--failed",
         "--with-id",
         "--id-file=%s" % self.idfile
     ]
     self.x = TestId()
     self.x.add_options(parser, env={})
     (options, args) = parser.parse_args(argv)
     self.config = Config()
     self.x.configure(options, self.config)
     self.config.plugins = PluginManager()
     self.config.plugins.addPlugin(Dataprovider())
     self.config.plugins.addPlugin(TestId())
     self.config.configure(argv)
Esempio n. 4
0
class TestIdTest(unittest.TestCase):
    tests_location = "tests/data/testid/testid.py"
    idfile_location = "data/testid/.noseids"

    def setUp(self):
        self.idfile = os.path.abspath(
            os.path.join(os.path.dirname(__file__), self.idfile_location))
        parser = optparse.OptionParser()
        argv = [
            # 0 is always program
            "lode_runner",
            "--failed",
            "--with-id",
            "--id-file=%s" % self.idfile
        ]
        self.x = TestId()
        self.x.add_options(parser, env={})
        (options, args) = parser.parse_args(argv)
        self.config = Config()
        self.x.configure(options, self.config)
        self.config.plugins = PluginManager()
        self.config.plugins.addPlugin(Dataprovider())
        self.config.plugins.addPlugin(TestId())
        self.config.configure(argv)

    def tearDown(self):
        try:
            os.remove(self.idfile)
        except OSError:
            pass

    def test_load_tests_path_with_no_info_in_idfile(self):
        names = self.x.loadTestsFromNames([self.tests_location])
        self.assertEqual((None, [self.tests_location]), names)

    def test_loaded_names_with_failing_tests_in_idfile(self):
        stream = StringIO()

        tests = TestLoader(config=self.config).loadTestsFromName(self.tests_location)
        result = LodeTestResult(stream, None, 0)
        tests.run(result)
        # generate needed idfile
        self.config.plugins.finalize(result)

        names = self.x.loadTestsFromNames([self.tests_location])
        loaded_tests = [(parse_test_name(name)[1], parse_test_name(name)[2]) for name in names[1]]
        self.assertEqual(
            [('DataprovidedTestCase','test_with_dataprovider_failing_on_everything_except_2_1'),
             ('DataprovidedTestCase','test_with_dataprovider_failing_on_everything_except_2_3')], loaded_tests)