コード例 #1
0
ファイル: background_test.py プロジェクト: Ingwar/amuse
 def _perform_the_testrun(self, directories, results_queue, previous_report = None):
     try:
         ensure_mpd_is_running()
         
         null_device = open('/dev/null')
         os.stdin = null_device
         report = MakeAReportOfATestRun(previous_report, results_queue)
         doctest = Doctest()
         doctest.enabled = True
         plugins = [doctest, report, Skip(), Capture()] 
         argv = ['nose', '-v']
         old_working_directory = os.getcwd()
         if not self.WORKING_DIRECTORY is None:
             argv.extend(['-w', self.WORKING_DIRECTORY])
             os.chdir(self.WORKING_DIRECTORY)
             
         argv.extend( directories)
         argv.extend(['--with-doctest', '--doctest-extension=txt'])
         
         result = TestProgram(exit = False, argv=argv, plugins=plugins);
         
         os.chdir(old_working_directory)
         results_queue.put(('test-report', report,) )
     except :
         results_queue.put(('test-error', 'Exception happened: ' + str(sys.exc_info()[0]) + " - " + str(sys.exc_info()[1]), ))
     finally:
         results_queue.put(None)
         MPI.Finalize()
コード例 #2
0
ファイル: test_plugins.py プロジェクト: jiffyclub/nose
 def test_collect_no_collect(self):
     # bug http://nose.python-hosting.com/ticket/55
     # we got "iteration over non-sequence" when no files match
     here = os.path.abspath(os.path.dirname(__file__))
     support = os.path.join(here, 'support')
     plug = Doctest()
     for test in plug.loadTestsFromFile(os.path.join(support, 'foo')):
         self.fail("Expected no tests, got %s" % test)
コード例 #3
0
 def test_collect_no_collect(self):
     # bug http://nose.python-hosting.com/ticket/55
     # we got "iteration over non-sequence" when no files match
     here = os.path.abspath(os.path.dirname(__file__))
     support = os.path.join(here, 'support')
     plug = Doctest()
     for test in plug.loadTestsFromFile(os.path.join(support, 'foo')):
         self.fail("Expected no tests, got %s" % test)
コード例 #4
0
    def test_add_options(self):
        # doctest plugin adds some options...
        conf = Config()
        opt = Bucket()
        parser = MockOptParser()
        plug = Doctest()

        plug.add_options(parser, {})
        o, d = parser.opts[0]
        assert o[0] == '--with-doctest'

        o2, d2 = parser.opts[1]
        assert o2[0] == '--doctest-tests'

        o3, d3 = parser.opts[2]
        assert o3[0] == '--doctest-extension'
コード例 #5
0
ファイル: test_plugins.py プロジェクト: jiffyclub/nose
    def test_collect_pymodule(self):
        here = os.path.dirname(__file__)
        support = os.path.join(here, 'support')
        if not support in sys.path:
            sys.path.insert(0, support)
        import foo.bar.buz

        conf = Config()
        opt = Bucket()
        plug = Doctest()
        plug.can_configure = True
        plug.configure(opt, conf)
        suite = plug.loadTestsFromModule(foo.bar.buz)
        expect = ['[afunc (foo.bar.buz)]']
        for test in suite:
            self.assertEqual(str(test), expect.pop(0))
コード例 #6
0
ファイル: test_plugins.py プロジェクト: jiffyclub/nose
    def test_add_options(self):
        # doctest plugin adds some options...
        conf = Config()
        opt = Bucket()
        parser = MockOptParser()
        plug = Doctest()

        plug.add_options(parser, {})
        o, d = parser.opts[0]
        assert o[0] == '--with-doctest'

        o2, d2 = parser.opts[1]
        assert o2[0] == '--doctest-tests'

        o3, d3 = parser.opts[2]
        assert o3[0] == '--doctest-extension'
コード例 #7
0
 def test_addresses(self):
     here = os.path.dirname(__file__)
     support = os.path.join(here, 'support')
     if not support in sys.path:
         sys.path.insert(0, support)
     import foo.bar.buz
     
     conf = Config()
     opt = Bucket()
     plug = Doctest()
     plug.can_configure = True
     plug.configure(opt, conf)
     suite = plug.loadTestsFromModule(foo.bar.buz)
     for test in suite:
         print test.address()
         file, mod, call = test.address()
         self.assertEqual(mod, 'foo.bar.buz')
         self.assertEqual(call, 'afunc')
コード例 #8
0
 def test_matches(self):
     # doctest plugin wants tests from all NON-test modules
     conf = Config()
     opt = Bucket()
     plug = Doctest()
     plug.can_configure = True
     plug.configure(opt, conf)
     assert not plug.matches('test')
     assert plug.matches('foo')
コード例 #9
0
ファイル: test_plugins.py プロジェクト: jiffyclub/nose
    def test_config(self):
        # test that configuration works properly when both environment
        # and command line specify a doctest extension
        parser = OptionParser()
        env = {'NOSE_DOCTEST_EXTENSION':'ext'}
        argv = ['--doctest-extension', 'txt']
        dtp = Doctest()
        dtp.add_options(parser, env)
        options, args = parser.parse_args(argv)

        print options
        print args
        self.assertEqual(options.doctestExtension, ['ext', 'txt'])

        env = {}
        parser = OptionParser()
        dtp.add_options(parser, env)
        options, args = parser.parse_args(argv)
        print options
        print args
        self.assertEqual(options.doctestExtension, ['txt'])
コード例 #10
0
ファイル: test_plugins.py プロジェクト: GaloisInc/echronos
    def test_config(self):
        # test that configuration works properly when both environment
        # and command line specify a doctest extension
        parser = OptionParser()
        env = {"NOSE_DOCTEST_EXTENSION": "ext"}
        argv = ["--doctest-extension", "txt"]
        dtp = Doctest()
        dtp.add_options(parser, env)
        options, args = parser.parse_args(argv)

        print(options)
        print(args)
        self.assertEqual(options.doctestExtension, ["ext", "txt"])

        env = {}
        parser = OptionParser()
        dtp.add_options(parser, env)
        options, args = parser.parse_args(argv)
        print(options)
        print(args)
        self.assertEqual(options.doctestExtension, ["txt"])
コード例 #11
0
    def test_config(self):
        # test that configuration works properly when both environment
        # and command line specify a doctest extension
        parser = OptionParser()
        env = {'NOSE_DOCTEST_EXTENSION': 'ext'}
        argv = ['--doctest-extension', 'txt']
        dtp = Doctest()
        dtp.add_options(parser, env)
        options, args = parser.parse_args(argv)

        print
        options
        print
        args
        self.assertEqual(options.doctestExtension, ['ext', 'txt'])

        env = {}
        parser = OptionParser()
        dtp.add_options(parser, env)
        options, args = parser.parse_args(argv)
        print
        options
        print
        args
        self.assertEqual(options.doctestExtension, ['txt'])
コード例 #12
0
    def test_addresses(self):
        here = os.path.dirname(__file__)
        support = os.path.join(here, 'support')
        if not support in sys.path:
            sys.path.insert(0, support)
        import foo.bar.buz

        conf = Config()
        opt = Bucket()
        plug = Doctest()
        plug.can_configure = True
        plug.configure(opt, conf)
        suite = plug.loadTestsFromModule(foo.bar.buz)
        for test in suite:
            print
            test.address()
            file, mod, call = test.address()
            self.assertEqual(mod, 'foo.bar.buz')
            self.assertEqual(call, None)
            for case in test:
                print
                case.address()
                file, mod, call = case.address()
                self.assertEqual(mod, 'foo.bar.buz')
                self.assertEqual(call, 'afunc')
コード例 #13
0
class TestDoctestPlugin(PluginTester, unittest.TestCase):
    activate = '--with-doctest'
    args = ['-v']
    plugins = [Doctest()]
    suitepath = os.path.join(support, 'dtt')

    def runTest(self):
        print str(self.output)

        assert 'Doctest: some_mod ... ok' in self.output
        assert 'Doctest: some_mod.foo ... ok' in self.output
        assert 'Ran 2 tests' in self.output
        assert str(self.output).strip().endswith('OK')
コード例 #14
0
    def _perform_the_testrun(self,
                             directories,
                             results_queue,
                             previous_report=None):
        try:
            ensure_mpd_is_running()

            null_device = open('/dev/null')
            os.stdin = null_device
            report = MakeAReportOfATestRun(previous_report, results_queue)
            doctest = Doctest()
            doctest.enabled = True
            plugins = [doctest, report, Skip(), Capture()]
            argv = ['nose', '-v']
            old_working_directory = os.getcwd()
            if not self.WORKING_DIRECTORY is None:
                argv.extend(['-w', self.WORKING_DIRECTORY])
                os.chdir(self.WORKING_DIRECTORY)

            argv.extend(directories)
            argv.extend(['--with-doctest', '--doctest-extension=txt'])

            result = TestProgram(exit=False, argv=argv, plugins=plugins)

            os.chdir(old_working_directory)
            results_queue.put((
                'test-report',
                report,
            ))
        except:
            results_queue.put((
                'test-error',
                'Exception happened: ' + str(sys.exc_info()[0]) + " - " +
                str(sys.exc_info()[1]),
            ))
        finally:
            results_queue.put(None)
            MPI.Finalize()
コード例 #15
0
ファイル: test_plugins.py プロジェクト: jiffyclub/nose
 def test_matches(self):
     # doctest plugin wants tests from all NON-test modules
     conf = Config()
     opt = Bucket()
     plug = Doctest()
     plug.can_configure = True
     plug.configure(opt, conf)
     assert not plug.matches('test')
     assert plug.matches('foo')
コード例 #16
0
class TestDoctestFiles(PluginTester, unittest.TestCase):
    activate = '--with-doctest'
    args = ['-v', '--doctest-extension=.txt']
    plugins = [Doctest()]
    suitepath = os.path.join(support, 'dtt', 'docs')

    def runTest(self):
        print str(self.output)

        expect = ['Doctest: doc.txt ... ok', 'Doctest: errdoc.txt ... FAIL']
        for line in self.output:
            if not line.strip():
                continue
            if line.startswith('='):
                break
            self.assertEqual(line.strip(), expect.pop(0))
コード例 #17
0
    def test_collect_txtfile(self):
        here = os.path.abspath(os.path.dirname(__file__))
        support = os.path.join(here, 'support')
        fn = os.path.join(support, 'foo', 'doctests.txt')

        conf = Config()
        opt = Bucket()
        plug = Doctest()
        plug.can_configure = True
        plug.configure(opt, conf)
        plug.extension = ['.txt']
        suite = plug.loadTestsFromFile(fn)
        for test in suite:
            assert str(test).endswith('doctests.txt')
            assert test.address(), "Test %s has no address"
コード例 #18
0
ファイル: test_plugins.py プロジェクト: jiffyclub/nose
    def test_collect_txtfile(self):
        here = os.path.abspath(os.path.dirname(__file__))
        support = os.path.join(here, 'support')
        fn = os.path.join(support, 'foo', 'doctests.txt')

        conf = Config()
        opt = Bucket()
        plug = Doctest()
        plug.can_configure = True
        plug.configure(opt, conf)
        plug.extension = ['.txt']
        suite = plug.loadTestsFromFile(fn)
        for test in suite:
            assert str(test).endswith('doctests.txt')
            assert test.address(), "Test %s has no address"
コード例 #19
0
    def test_collect_pymodule(self):
        here = os.path.dirname(__file__)
        support = os.path.join(here, 'support')
        if not support in sys.path:
            sys.path.insert(0, support)
        import foo.bar.buz

        conf = Config()
        opt = Bucket()
        plug = Doctest()
        plug.can_configure = True
        plug.configure(opt, conf)
        suite = plug.loadTestsFromModule(foo.bar.buz)
        expect = ['[afunc (foo.bar.buz)]']
        for test in suite:
            self.assertEqual(str(test), expect.pop(0))
コード例 #20
0
ファイル: iptest.py プロジェクト: g2p/ipython
#!/usr/bin/env python
"""Nose-based test runner.
"""

from nose.core import main
from nose.plugins.builtin import plugins
from nose.plugins.doctests import Doctest

import ipdoctest
from ipdoctest import IPDocTestRunner

if __name__ == '__main__':
    print 'WARNING: this code is incomplete!'
    print

    pp = [x() for x in plugins]  # activate all builtin plugins first
    main(testRunner=IPDocTestRunner(),
         plugins=pp+[ipdoctest.IPythonDoctest(),Doctest()])
コード例 #21
0
ファイル: test_plugins.py プロジェクト: jiffyclub/nose
    def test_want_file(self):
        # doctest plugin can select module and/or non-module files
        conf = Config()
        opt = Bucket()
        plug = Doctest()
        plug.can_configure = True
        plug.configure(opt, conf)

        assert plug.wantFile('foo.py')
        assert not plug.wantFile('bar.txt')
        assert not plug.wantFile('buz.rst')
        assert not plug.wantFile('bing.mov')

        plug.extension = ['.txt', '.rst']
        assert plug.wantFile('/path/to/foo.py')
        assert plug.wantFile('/path/to/bar.txt')
        assert plug.wantFile('/path/to/buz.rst')
        assert not plug.wantFile('/path/to/bing.mov')
コード例 #22
0
            print("- _mapnik.so path: %s" % mapnik._mapnik.__file__)
        print("- Input plugins path: %s" % mapnik.inputpluginspath)
        print("- Font path: %s" % mapnik.fontscollectionpath)
        print('')
        print("- Running nosetests:")
        print('')

    argv = [
        __file__, '--exe', '--with-todo', '--with-doctest', '--doctest-tests'
    ]

    if not quiet:
        argv.append('-v')

    if verbose:
        # 3 * '-v' gets us debugging information from nose
        argv.append('-v')
        argv.append('-v')

    dirname = os.path.dirname(sys.argv[0])
    argv.extend(['-w', dirname + '/python_tests'])

    if not nose.run(argv=argv, plugins=[TodoPlugin(), Doctest()]):
        sys.exit(1)
    else:
        sys.exit(0)


if __name__ == "__main__":
    main()
コード例 #23
0
ファイル: iptest.py プロジェクト: sainjusajan/django-oscar
#!/usr/bin/env python
"""Nose-based test runner.
"""
from __future__ import print_function

from nose.core import main
from nose.plugins.builtin import plugins
from nose.plugins.doctests import Doctest

from . import ipdoctest
from .ipdoctest import IPDocTestRunner

if __name__ == '__main__':
    print('WARNING: this code is incomplete!')
    print()

    pp = [x() for x in plugins]  # activate all builtin plugins first
    main(testRunner=IPDocTestRunner(),
         plugins=pp +
         [ipdoctest.IPythonDoctest(), Doctest()])
コード例 #24
0
    def test_want_file(self):
        # doctest plugin can select module and/or non-module files
        conf = Config()
        opt = Bucket()
        plug = Doctest()
        plug.can_configure = True
        plug.configure(opt, conf)

        assert plug.wantFile('foo.py')
        assert not plug.wantFile('bar.txt')
        assert not plug.wantFile('buz.rst')
        assert not plug.wantFile('bing.mov')

        plug.extension = ['.txt', '.rst']
        assert plug.wantFile('/path/to/foo.py')
        assert plug.wantFile('/path/to/bar.txt')
        assert plug.wantFile('/path/to/buz.rst')
        assert not plug.wantFile('/path/to/bing.mov')
コード例 #25
0
    def test_want_file(self):
        # doctest plugin can select module and/or non-module files
        conf = Config()
        opt = Bucket()
        plug = Doctest()
        plug.can_configure = True
        plug.configure(opt, conf)

        assert plug.wantFile("foo.py")
        assert not plug.wantFile("bar.txt")
        assert not plug.wantFile("buz.rst")
        assert not plug.wantFile("bing.mov")

        plug.extension = [".txt", ".rst"]
        assert plug.wantFile("/path/to/foo.py")
        assert plug.wantFile("/path/to/bar.txt")
        assert plug.wantFile("/path/to/buz.rst")
        assert not plug.wantFile("/path/to/bing.mov")
コード例 #26
0
def main():
    try:
        opts, args = getopt.getopt(sys.argv[1:], "hvqp:", ["help", "prefix="])
    except getopt.GetoptError as err:
        print(str(err))
        usage()
        sys.exit(2)

    prefix = None
    verbose = False
    quiet = False

    for o, a in opts:
        if o == "-q":
            quiet = True
        elif o == "-v":
            verbose = True
        elif o in ("-h", "--help"):
            usage()
            sys.exit()
        elif o in ("-p", "--prefix"):
            prefix = a
        else:
            assert False, "Unhandled option"

    if quiet and verbose:
        usage()
        sys.exit(2)

    if prefix:
        # Allow python to find libraries for testing on the buildbot
        sys.path.insert(
            0,
            os.path.join(prefix,
                         "lib/python%s/site-packages" % sys.version[:3]))

    import mapnik

    if not quiet:
        print("- mapnik path: %s" % mapnik.__file__)
        if hasattr(mapnik, '_mapnik'):
            print("- _mapnik.so path: %s" % mapnik._mapnik.__file__)
        if hasattr(mapnik, 'inputpluginspath'):
            print("- Input plugins path: %s" % mapnik.inputpluginspath)
        if 'MAPNIK_INPUT_PLUGINS_DIRECTORY' in os.environ:
            print("- MAPNIK_INPUT_PLUGINS_DIRECTORY env: %s" %
                  os.environ.get('MAPNIK_INPUT_PLUGINS_DIRECTORY'))
        if hasattr(mapnik, 'fontscollectionpath'):
            print("- Font path: %s" % mapnik.fontscollectionpath)
        if 'MAPNIK_FONT_DIRECTORY' in os.environ:
            print("- MAPNIK_FONT_DIRECTORY env: %s" %
                  os.environ.get('MAPNIK_FONT_DIRECTORY'))
        print('')
        print("- Running nosetests:")
        print('')

    argv = [
        __file__, '--exe', '--with-todo', '--with-doctest', '--doctest-tests'
    ]

    if not quiet:
        argv.append('-v')

    if verbose:
        # 3 * '-v' gets us debugging information from nose
        argv.append('-v')
        argv.append('-v')

    dirname = os.path.dirname(sys.argv[0])
    argv.extend(['-w', os.path.join(dirname, 'python_tests')])

    if not nose.run(argv=argv, plugins=[TodoPlugin(), Doctest()]):
        sys.exit(1)
    else:
        sys.exit(0)