Hello Divadsn, John Vandenberg, MtDu, Framawiki, jenkins-bot, Xqt, Zoranzoki21,

I'd like you to do a code review.  Please visit

    https://gerrit.wikimedia.org/r/405292

to review the following change.


Change subject: Revert "Replace assertRaises with assertRaisesRegex in 
isbn_tests.py"
......................................................................

Revert "Replace assertRaises with assertRaisesRegex in isbn_tests.py"

This reverts commit 9a13055ce9c130d832ebd273681e7bf4d5dd71a7.
We can use https://gerrit.wikimedia.org/r/#/c/399348/ instead.

Bug: T185317
Change-Id: I9d2e576e386b04592520fa7533b58e03bc370f9d
---
M tests/isbn_tests.py
1 file changed, 15 insertions(+), 53 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/92/405292/1

diff --git a/tests/isbn_tests.py b/tests/isbn_tests.py
index ae867d2..df00417 100644
--- a/tests/isbn_tests.py
+++ b/tests/isbn_tests.py
@@ -34,29 +34,10 @@
 else:
     AnyIsbnValidationException = IsbnExc
 
-ISBNINVALIDCHECKSUM_RE = (
-    r'The ISBN checksum of ([A-Z0-9]*) is incorrect'
-)
-
-ISBNINVALIDLENGTH_RE = (
-    r'The ISBN ([A-Z0-9]*) is not (10|13) digits long'
-)
-
-ISBNINVALIDCHARACTERS_RE = (
-    r'The ISBN ([A-Z0-9]*) contains invalid characters'
-)
-
 
 class TestCosmeticChangesISBN(DefaultDrySiteTestCase):
 
     """Test CosmeticChanges ISBN fix."""
-
-    INVALIDNUMBERLENGTH_RE = (
-        r'The number has an invalid length'
-    )
-    INVALIDNUMBERCHECKSUM_RE = (
-        r'The number\'s checksum or check digit is invalid'
-    )
 
     def test_valid_isbn(self):
         """Test ISBN."""
@@ -73,25 +54,17 @@
         cc = CosmeticChangesToolkit(self.site, namespace=0)
 
         # Invalid characters
-        self.assertRaisesRegex(AnyIsbnValidationException,
-                               (ISBNINVALIDLENGTH_RE + '|' +
-                                self.INVALIDNUMBERLENGTH_RE),
-                               cc.fix_ISBN, 'ISBN 0975229LOL')
+        self.assertRaises(AnyIsbnValidationException,
+                          cc.fix_ISBN, 'ISBN 0975229LOL')
         # Invalid checksum
-        self.assertRaisesRegex(AnyIsbnValidationException,
-                               (ISBNINVALIDCHECKSUM_RE + '|' +
-                                self.INVALIDNUMBERCHECKSUM_RE),
-                               cc.fix_ISBN, 'ISBN 0975229801')
+        self.assertRaises(AnyIsbnValidationException,
+                          cc.fix_ISBN, 'ISBN 0975229801')
         # Invalid length
-        self.assertRaisesRegex(AnyIsbnValidationException,
-                               (ISBNINVALIDLENGTH_RE + '|' +
-                                self.INVALIDNUMBERLENGTH_RE),
-                               cc.fix_ISBN, 'ISBN 09752298')
+        self.assertRaises(AnyIsbnValidationException,
+                          cc.fix_ISBN, 'ISBN 09752298')
         # X in the middle
-        self.assertRaisesRegex(AnyIsbnValidationException,
-                               (ISBNINVALIDCHARACTERS_RE + '|' +
-                                self.INVALIDNUMBERLENGTH_RE),
-                               cc.fix_ISBN, 'ISBN 09752X9801')
+        self.assertRaises(AnyIsbnValidationException,
+                          cc.fix_ISBN, 'ISBN 09752X9801')
 
     def test_ignore_invalid_isbn(self):
         """Test fixing ISBN numbers with an invalid ISBN."""
@@ -104,10 +77,6 @@
 class TestIsbn(TestCase):
 
     """Test ISBN-related classes and helper functions."""
-
-    ISBNXINTHEMIDDLE_RE = (
-        r'ISBN ([A-Z0-9]*): X is only allowed at the end of the ISBN'
-    )
 
     net = False
 
@@ -125,14 +94,10 @@
         self.assertEqual(isbn13.code, '978-0-9752298-0-4')
 
         # Errors
-        self.assertRaisesRegex(IsbnExc, ISBNINVALIDCHARACTERS_RE,
-                               ISBN10, '0975229LOL')  # Invalid characters
-        self.assertRaisesRegex(IsbnExc, ISBNINVALIDCHECKSUM_RE,
-                               ISBN10, '0975229801')  # Invalid checksum
-        self.assertRaisesRegex(IsbnExc, ISBNINVALIDLENGTH_RE,
-                               ISBN10, '09752298')  # Invalid length
-        self.assertRaisesRegex(IsbnExc, self.ISBNXINTHEMIDDLE_RE,
-                               ISBN10, '09752X9801')  # X in the middle
+        self.assertRaises(IsbnExc, ISBN10, '0975229LOL')  # Invalid characters
+        self.assertRaises(IsbnExc, ISBN10, '0975229801')  # Invalid checksum
+        self.assertRaises(IsbnExc, ISBN10, '09752298')  # Invalid length
+        self.assertRaises(IsbnExc, ISBN10, '09752X9801')  # X in the middle
 
     def test_isbn13(self):
         """Test ISBN13."""
@@ -146,12 +111,9 @@
         self.assertEqual(isbn.code, '9788090273412')
 
         # Errors
-        self.assertRaisesRegex(IsbnExc, ISBNINVALIDCHARACTERS_RE,
-                               ISBN13, '9783161484LOL')  # Invalid characters
-        self.assertRaisesRegex(IsbnExc, ISBNINVALIDCHECKSUM_RE,
-                               ISBN13, '9783161484105')  # Invalid checksum
-        self.assertRaisesRegex(IsbnExc, ISBNINVALIDLENGTH_RE,
-                               ISBN13, '9783161484')  # Invalid length
+        self.assertRaises(IsbnExc, ISBN13, '9783161484LOL')  # Invalid chars
+        self.assertRaises(IsbnExc, ISBN13, '9783161484105')  # Invalid checksum
+        self.assertRaises(IsbnExc, ISBN13, '9783161484')  # Invalid length
 
     def test_general(self):
         """Test things that apply both to ISBN10 and ISBN13."""

-- 
To view, visit https://gerrit.wikimedia.org/r/405292
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9d2e576e386b04592520fa7533b58e03bc370f9d
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Dalba <dalba.w...@gmail.com>
Gerrit-Reviewer: Divadsn <divad.nnamtd...@gmail.com>
Gerrit-Reviewer: Framawiki <framaw...@tools.wmflabs.org>
Gerrit-Reviewer: John Vandenberg <jay...@gmail.com>
Gerrit-Reviewer: MtDu <justin.d...@gmail.com>
Gerrit-Reviewer: Xqt <i...@gno.de>
Gerrit-Reviewer: Zoranzoki21 <zorandori4...@gmail.com>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to