Esempio n. 1
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')
Esempio n. 2
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')
 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')
Esempio n. 4
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"
    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"
Esempio n. 6
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))
    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))
Esempio n. 8
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')
Esempio n. 9
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")
    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')
Esempio n. 11
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')