jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/758903 )
Change subject: [tests] Add LinkTestWikiEn class to prevent code duplication ......................................................................
[tests] Add LinkTestWikiEn class to prevent code duplication
Change-Id: I5cef1436998285aff02e29c21efdf8b0ea4b5cb7 --- M tests/link_tests.py 1 file changed, 12 insertions(+), 52 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/tests/link_tests.py b/tests/link_tests.py index 601acd5..10a43cc 100644 --- a/tests/link_tests.py +++ b/tests/link_tests.py @@ -239,9 +239,9 @@ cache = True
-class TestPartiallyQualifiedExplicitLinkSameSiteParser(LinkTestCase): +class LinkTestWikiEn(LinkTestCase):
- """Link tests.""" + """Link tests on wikipedia:en."""
family = 'wikipedia' code = 'en' @@ -252,6 +252,11 @@ config.mylang = 'en' config.family = 'wikipedia'
+ +class TestPartiallyQualifiedExplicitLinkSameSiteParser(LinkTestWikiEn): + + """Link tests.""" + def test_partially_qualified_NS0_code(self): """Test ':wikipedia:Main Page' on enwp is namespace 4.""" link = Link(':wikipedia:Main Page') @@ -285,19 +290,10 @@ self.assertEqual(link.namespace, 1)
-class TestPartiallyQualifiedExplicitLinkDifferentCodeParser(LinkTestCase): +class TestPartiallyQualifiedExplicitLinkDifferentCodeParser(LinkTestWikiEn):
"""Link tests."""
- family = 'wikipedia' - code = 'en' - - def setUp(self): - """Setup tests.""" - super().setUp() - config.mylang = 'en' - config.family = 'wikipedia' - def test_partially_qualified_NS0_family(self): """Test ':en:Main Page' on dewp is namespace 0.""" link = Link(':en:Main Page') @@ -368,19 +364,10 @@ self.assertEqual(link.namespace, 4)
-class TestFullyQualifiedExplicitLinkSameFamilyParser(LinkTestCase): +class TestFullyQualifiedExplicitLinkSameFamilyParser(LinkTestWikiEn):
"""Link tests."""
- family = 'wikipedia' - code = 'en' - - def setUp(self): - """Setup tests.""" - super().setUp() - config.mylang = 'en' - config.family = 'wikipedia' - def test_fully_qualified_NS0_code(self): """Test ':en:wikipedia:Main Page' on enwp is namespace 4.""" link = Link(':en:wikipedia:Main Page') @@ -604,19 +591,10 @@ # ---- Tests of a Link without colons, which shouldn't be interwikis, follow.
-class TestPartiallyQualifiedImplicitLinkSameSiteParser(LinkTestCase): +class TestPartiallyQualifiedImplicitLinkSameSiteParser(LinkTestWikiEn):
"""Test partially qualified links to same site."""
- family = 'wikipedia' - code = 'en' - - def setUp(self): - """Setup tests.""" - super().setUp() - config.mylang = 'en' - config.family = 'wikipedia' - def test_partially_qualified_NS0_code(self): """Test 'wikipedia:Main Page' on enwp is namespace 4.""" link = Link('wikipedia:Main Page') @@ -650,19 +628,10 @@ self.assertEqual(link.namespace, 1)
-class TestPartiallyQualifiedImplicitLinkDifferentCodeParser(LinkTestCase): +class TestPartiallyQualifiedImplicitLinkDifferentCodeParser(LinkTestWikiEn):
"""Test partially qualified links to different code."""
- family = 'wikipedia' - code = 'en' - - def setUp(self): - """Setup tests.""" - super().setUp() - config.mylang = 'en' - config.family = 'wikipedia' - def test_partially_qualified_NS0_family(self): """Test 'en:Main Page' on dewp is namespace 0.""" link = Link('en:Main Page') @@ -710,19 +679,10 @@ self.assertEqual(link.namespace, 1)
-class TestFullyQualifiedImplicitLinkSameFamilyParser(LinkTestCase): +class TestFullyQualifiedImplicitLinkSameFamilyParser(LinkTestWikiEn):
"""Link tests."""
- family = 'wikipedia' - code = 'en' - - def setUp(self): - """Setup tests.""" - super().setUp() - config.mylang = 'en' - config.family = 'wikipedia' - def test_fully_qualified_NS0_code(self): """Test 'en:wikipedia:Main Page' on enwp is namespace 4.""" link = Link('en:wikipedia:Main Page')