Esempio n. 1
0
 def test_completionFile(self):
     """
     --completion-file causes a version string to be output
     """
     argv = ['--completion-file']
     cmdline.main(argv, testing=True)
     self.assertIn('shell_completion.sh', self.s.getvalue())
Esempio n. 2
0
 def test_completionFile(self):
     """
     --completion-file causes a version string to be output
     """
     config.sys.argv = ['', '--completion-file']
     cmdline.main(testing=True)
     self.assertIn('shell_completion.sh', self.s.getvalue())
Esempio n. 3
0
File: setup.py Progetto: jayvdb/grip
 def run_tests(self):
     from green.cmdline import main
     main(argv=['-r', '-vv'])
     import coverage
     cov = coverage.Coverage()
     cov.load()
     cov.html_report()
Esempio n. 4
0
 def test_options(self):
     """
     --options causes options to be output
     """
     cmdline.sys.argv = ['', '--options']
     cmdline.main(testing=True)
     self.assertIn('--options', self.s.getvalue())
     self.assertIn('--version', self.s.getvalue())
Esempio n. 5
0
 def test_noTestsCreatesEmptyTestSuite(self):
     "If loadTargets doesn't find any tests, an empty test suite is created"
     save_TestSuite = cmdline.unittest.suite.TestSuite
     cmdline.unittest.suite.TestSuite = MagicMock()
     cmdline.sys.argv = ['', '/tmp/non-existent/path']
     cmdline.main(testing=True)
     cmdline.unittest.suite.TestSuite.assert_called_with()
     cmdline.unittest.suite.TestSuite = save_TestSuite
Esempio n. 6
0
 def test_options(self):
     """
     --options causes options to be output
     """
     argv = ['--options']
     cmdline.main(argv, testing=True)
     self.assertIn('--options', self.s.getvalue())
     self.assertIn('--version', self.s.getvalue())
Esempio n. 7
0
 def test_version(self):
     """
     --version causes a version string to be output
     """
     cmdline.sys.argv = ['', '--version']
     cmdline.main(testing=True)
     self.assertIn('Green', self.s.getvalue())
     self.assertIn('Python', self.s.getvalue())
Esempio n. 8
0
 def test_noTestsCreatesEmptyTestSuite(self):
     """
     If loadTargets doesn't find any tests, an empty test suite is created.
     Coverage test, since loading the module inside the main function (due
     to coverage handling constraints) prevents injecting a mock.
     """
     argv = ['', '/tmp/non-existent/path']
     cmdline.main(argv, testing=True)
Esempio n. 9
0
 def test_noTestsCreatesEmptyTestSuite(self):
     """
     If loadTargets doesn't find any tests, an empty test suite is created.
     Coverage test, since loading the module inside the main function (due
     to coverage handling constraints) prevents injecting a mock.
     """
     cmdline.sys.argv = ['', '/tmp/non-existent/path']
     cmdline.main(testing=True)
Esempio n. 10
0
 def test_version(self):
     """
     --version causes a version string to be output
     """
     argv = ['--version']
     cmdline.main(argv, testing=True)
     self.assertIn('Green', self.s.getvalue())
     self.assertIn('Python', self.s.getvalue())
Esempio n. 11
0
 def test_completions(self):
     "--completions returns completions (the loader module tests deeper)"
     cwd = os.getcwd()
     path = os.path.abspath(__file__)
     os.chdir(os.path.dirname(os.path.dirname(os.path.dirname(path))))
     config.sys.argv = ['', '--completions', 'green']
     cmdline.main(testing=True)
     os.chdir(cwd)
     self.assertIn('green.test', self.s.getvalue())
Esempio n. 12
0
 def test_notTesting(self):
     "We actually attempt running loadTargets (coverage test)"
     tmpdir = tempfile.mkdtemp()
     cwd = os.getcwd()
     os.chdir(tmpdir)
     config.sys.argv = ['', tmpdir]
     cmdline.main()
     os.chdir(cwd)
     shutil.rmtree(tmpdir)
Esempio n. 13
0
 def test_coverage(self):
     "If coverage and --run-coverage, then coverage is started"
     save_coverage = config.coverage
     config.coverage = MagicMock()
     config.sys.argv = ['', '--run-coverage', '--omit-patterns=abc']
     cmdline.main(testing=True, coverage_testing=True)
     config.coverage.coverage.assert_called_with(
             data_file=u'.coverage', omit=['abc'])
     config.coverage = save_coverage
Esempio n. 14
0
 def test_configFileDebug(self):
     "A debug message is output if a config file is loaded (coverage test)"
     tmpdir = tempfile.mkdtemp()
     filename = os.path.join(tmpdir, 'config')
     fh = open(filename, 'w')
     fh.write("debug = 2")
     fh.close()
     cmdline.sys.argv = ['', '-dd', '--config', filename]
     cmdline.main(testing=True)
     shutil.rmtree(tmpdir)
Esempio n. 15
0
 def test_omit_patterns(self):
     "Omit pattern gets parsed"
     save_coverage = config.coverage
     config.coverage = MagicMock()
     cov = MagicMock()
     config.coverage.coverage.return_value = cov
     config.sys.argv = ['', '--run-coverage', '--omit-patterns', 'a,b']
     cmdline.main(testing=True, coverage_testing=True)
     self.assertEqual(cov.report.mock_calls[0][2]['omit'], ['a', 'b'])
     config.coverage = save_coverage
Esempio n. 16
0
 def test_completions(self):
     """
     --completions returns completions (the loader module tests deeper)
     """
     cwd = os.getcwd()
     path = os.path.abspath(__file__)
     os.chdir(os.path.dirname(os.path.dirname(os.path.dirname(path))))
     argv = ['--completions', 'green']
     cmdline.main(argv, testing=True)
     os.chdir(cwd)
     self.assertIn('green.test', self.s.getvalue())
Esempio n. 17
0
 def test_debug(self):
     "--debug causes the log-level to be set to debug"
     config.sys.argv = ['', '--debug']
     saved_basicConfig = config.logging.basicConfig
     config.logging.basicConfig = MagicMock()
     cmdline.main(testing=True)
     config.logging.basicConfig.assert_called_with(
         level=logging.DEBUG,
         format="%(asctime)s %(levelname)9s %(message)s",
         datefmt="%Y-%m-%d %H:%M:%S")
     config.logging.basicConfig = saved_basicConfig
Esempio n. 18
0
 def test_configFileDebug(self):
     """
     A debug message is output if a config file is loaded (coverage test)
     """
     tmpdir = tempfile.mkdtemp()
     filename = os.path.join(tmpdir, 'config')
     fh = open(filename, 'w')
     fh.write("debug = 2")
     fh.close()
     argv = ['-dd', '--config', filename]
     cmdline.main(argv, testing=True)
     shutil.rmtree(tmpdir)
Esempio n. 19
0
 def test_notTesting(self):
     """
     We actually attempt running loadTargets (coverage test)
     """
     tmpdir = tempfile.mkdtemp()
     cwd = os.getcwd()
     os.chdir(tmpdir)
     sys.path.insert(0, cwd)
     argv = [tmpdir]
     cmdline.main(argv)
     os.chdir(cwd)
     del (sys.path[0])
     shutil.rmtree(tmpdir)
Esempio n. 20
0
    def test_generate_junit_test_report(self):
        """
        Test that a report is generated when we use the '--junit-report' option.
        """
        tmpdir = tempfile.mkdtemp()
        report = join(tmpdir, "test_report.xml")
        self.assertFalse(isfile(report))

        argv = ["--junit-report", report]
        cmdline.main(argv, testing=True)

        self.assertTrue(isfile(report))
        shutil.rmtree(tmpdir)
Esempio n. 21
0
 def test_debug(self):
     """
     --debug causes the log-level to be set to debug
     """
     config.sys.argv = ['', '--debug']
     saved_basicConfig = config.logging.basicConfig
     self.addCleanup(setattr, config.logging, 'basicConfig', saved_basicConfig)
     config.logging.basicConfig = MagicMock()
     cmdline.main(testing=True)
     config.logging.basicConfig.assert_called_with(
         level=logging.DEBUG,
         format="%(asctime)s %(levelname)9s %(message)s",
         datefmt="%Y-%m-%d %H:%M:%S")
Esempio n. 22
0
 def test_noCoverage(self):
     "The absence of coverage prompts a return code of 3"
     save_stdout = config.sys.stdout
     config.sys.stdout = MagicMock()
     save_coverage = config.coverage
     config.coverage = None
     config.sys.argv = ['', '--run-coverage']
     self.assertEqual(cmdline.main(), 3)
     config.coverage = save_coverage
     config.sys.stdout = save_stdout
Esempio n. 23
0
 def test_noCoverage(self):
     """
     The absence of coverage prompts a return code of 3
     """
     save_stdout = config.sys.stdout
     config.sys.stdout = MagicMock()
     save_coverage = config.coverage
     config.coverage = None
     config.sys.argv = ['', '--run-coverage']
     self.assertEqual(cmdline.main(), 3)
     config.coverage = save_coverage
     config.sys.stdout = save_stdout
Esempio n. 24
0
    def run(self):
        self.ensure_finalized()

        if self.distribution.install_requires:
            self.distribution.fetch_build_eggs(self.distribution.install_requires)
        if self.distribution.tests_require:
            self.distribution.fetch_build_eggs(self.distribution.tests_require)

        script_args = self.distribution.script_args[1:]
        if self.distribution.test_suite is not None:
            script_args.append(self.distribution.test_suite)

        error_code = main(script_args)
        if error_code:
            sys.exit(error_code)
Esempio n. 25
0
    def run(self):
        self.ensure_finalized()

        if self.distribution.install_requires:
            self.distribution.fetch_build_eggs(
                self.distribution.install_requires)
        if self.distribution.tests_require:
            self.distribution.fetch_build_eggs(
                self.distribution.tests_require)

        script_args = self.distribution.script_args[1:]
        if self.distribution.test_suite is not None:
            script_args.append(self.distribution.test_suite)

        error_code = main(script_args)
        if error_code:
            sys.exit(error_code)
Esempio n. 26
0
 def test_disableWindowsSupport(self):
     """
     --disable-windows
     """
     argv = ['--disable-windows']
     cmdline.main(argv, testing=True)
Esempio n. 27
0
 def test_disableWindowsSupport(self):
     """
     --disable-windows
     """
     cmdline.sys.argv = ['', '--disable-windows']
     cmdline.main(testing=True)
Esempio n. 28
0
 def test_disableTermcolor(self):
     """
     --notermcolor causes coverage of the line disabling termcolor
     """
     argv = ['--notermcolor']
     cmdline.main(argv, testing=True)
Esempio n. 29
0
 def test_disableWindowsSupport(self):
     """
     --disable-windows
     """
     cmdline.sys.argv = ['', '--disable-windows']
     cmdline.main(testing=True)
Esempio n. 30
0
 def test_disableTermcolor(self):
     """
     --notermcolor causes coverage of the line disabling termcolor
     """
     cmdline.sys.argv = ['', '--notermcolor']
     cmdline.main(testing=True)