Пример #1
0
            """__unicode__ should return type unicode."""
            self.assertIsInstance(self.object_under_test.__unicode__(), UnicodeType)


class LiteralTests(Shared.SparqlNodeTests):
    """Tests for sparql.Literal."""

    net = False
    object_under_test = sparql.Literal({'datatype': '', 'lang': 'en', 'value': 'value'})


class BnodeTests(Shared.SparqlNodeTests):
    """Tests for sparql.Bnode."""

    net = False
    object_under_test = sparql.Bnode({'value': 'Foo'})


class URITests(Shared.SparqlNodeTests):
    """Tests for sparql.URI."""

    net = False
    object_under_test = sparql.URI({'value': 'http://foo.com'}, 'http://bar.com')


if __name__ == '__main__':  # pragma: no cover
    try:
        unittest.main()
    except SystemExit:
        pass
        self.assertRaises(Error, mysite.movepage, mainpage, mainpage.title(),
                          'test')

        page_from = self.get_missing_article()
        if not page_from.exists():
            self.assertRaises(NoPage, mysite.movepage, page_from, 'Main Page',
                              'test')


class TestWikibaseSaveTest(WikibaseTestCase):
    """Test case for WikibasePage.save on Wikidata test site."""

    family = 'wikidata'
    code = 'test'

    user = True
    write = -1

    def test_itempage_save(self):
        """Test ItemPage save method inherited from superclass Page."""
        repo = self.get_repo()
        item = pywikibot.ItemPage(repo, 'Q6')
        self.assertRaises(pywikibot.PageNotSaved, item.save)


if __name__ == '__main__':
    try:
        unittest.main()
    except SystemExit:
        pass
Пример #3
0
class TestPwb(PwbTestCase):

    """
    Test pwb.py functionality.

    This is registered as a Site test because it will not run
    without a user-config.py
    """

    # site must be explicitly set for pwb tests. This test does not require
    # network access, because tests/pwb/print_locals.py does not use
    # handle_args, etc. so version.py doesnt talk on the network.
    site = False
    net = False

    def testScriptEnvironment(self):
        """
        Test environment of pywikibot.

        Make sure the environment is not contaminated, and is the same as
        the environment we get when directly running a script.
        """
        direct = execute([sys.executable, '-m', 'tests.pwb.print_locals'])
        vpwb = execute_pwb([print_locals_test_script])
        self.maxDiff = None
        self.assertEqual(direct['stdout'], vpwb['stdout'])

if __name__ == "__main__":
    unittest.main(verbosity=10)
    def test_env(self):
        """
        Test external environment of pywikibot.

        Make sure the environment is not contaminated, and is the same as
        the environment we get when directly running a script.
        """
        self._do_check('print_env')

    def test_locals(self):
        """
        Test internal environment of pywikibot.

        Make sure the environment is not contaminated, and is the same as
        the environment we get when directly running a script.
        """
        self._do_check('print_locals')

    def test_unicode(self):
        """Test printing unicode in pywikibot."""
        (direct, vpwb) = self._do_check('print_unicode')

        self.assertEqual('Häuser', direct['stdout'].strip())
        self.assertEqual('Häuser', direct['stderr'].strip())
        self.assertEqual('Häuser', vpwb['stdout'].strip())
        self.assertEqual('Häuser', vpwb['stderr'].strip())


if __name__ == "__main__":
    unittest.main(verbosity=10)