jenkins-bot merged this change.

View Change

Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
Revert "[IMPR][TEST] Add references under templates in existing section"

This reverts commit 3c05747eb6bd97d231a5d0a134c85a7f221ebf63.

Bug: T188175
Change-Id: I2b5d4f4d22c4a543b6e407db9e8181c94aada4a1
---
M scripts/noreferences.py
D tests/noreferences_tests.py
2 files changed, 4 insertions(+), 51 deletions(-)

diff --git a/scripts/noreferences.py b/scripts/noreferences.py
index b3fbde3..ddf43a1 100755
--- a/scripts/noreferences.py
+++ b/scripts/noreferences.py
@@ -566,14 +566,11 @@
pywikibot.output(
'Adding references tag to existing %s section...\n'
% section)
- templates_or_comments = re.compile(
- r'^((?:\s*(?:\{\{[^\{\}]*?\}\}|<!--.*?-->))*)',
- flags=re.DOTALL)
new_text = (
- oldText[:match.end()]
- + templates_or_comments.sub(
- r'\1\n{0}\n'.format(self.referencesText),
- oldText[match.end():]))
+ oldText[:match.end()] + '\n' +
+ self.referencesText + '\n' +
+ oldText[match.end():]
+ )
return new_text
else:
break
diff --git a/tests/noreferences_tests.py b/tests/noreferences_tests.py
deleted file mode 100644
index d9661a9..0000000
--- a/tests/noreferences_tests.py
+++ /dev/null
@@ -1,44 +0,0 @@
-# -*- coding: utf-8 -*-
-"""Test noreferences bot module."""
-#
-# (C) Pywikibot team, 2018
-#
-# Distributed under the terms of the MIT license.
-#
-from __future__ import absolute_import, unicode_literals
-
-import pywikibot
-
-from scripts.noreferences import NoReferencesBot
-
-from tests.aspects import TestCase, unittest
-
-
-class TestAddingReferences(TestCase):
- """Test adding references to section."""
-
- family = 'wikipedia'
- code = 'cs'
-
- def test_add(self):
- """Test adding references section."""
- page = pywikibot.Page(self.site, 'foo')
- bot = NoReferencesBot()
- page.text = '== Reference ==\n* [http://www.baz.org Baz]'
- new_text = bot.addReferences(page.text)
- expected = ('== Reference ==\n<references />'
- '\n\n* [http://www.baz.org Baz]')
- self.assertEqual(new_text, expected)
-
- def test_add_under_templates(self):
- """Test adding references section under templates in section."""
- page = pywikibot.Page(self.site, 'foo')
- bot = NoReferencesBot()
- page.text = '== Reference ==\n{{Překlad|en|Baz|123456}}'
- new_text = bot.addReferences(page.text)
- expected = page.text + '\n<references />\n'
- self.assertEqual(new_text, expected)
-
-
-if __name__ == '__main__':
- unittest.main()

To view, visit change 414103. To unsubscribe, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I2b5d4f4d22c4a543b6e407db9e8181c94aada4a1
Gerrit-Change-Number: 414103
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: John Vandenberg <jayvdb@gmail.com>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444@gmail.com>
Gerrit-Reviewer: jenkins-bot <>