tests.diff_tests module#

Test diff module.

class tests.diff_tests.TestCherryPick(*args, **kwargs)[source]#

Bases: DisableSiteMixin, TestCase

Test cherry_pick method.

abstract_class = False#
check_headers(mock)[source]#

Check if all headers were added to output.

diff_by_letter_message = '<<lightred>>- o\n<<default>><<lightred>>- l\n<<default>><<lightred>>- d\n<<default>><<lightgreen>>+ n\n<<default>><<lightgreen>>+ e\n<<default>><<lightgreen>>+ w\n<<default>>'#
diff_message = '<<lightred>>- old\n<<default>><<lightgreen>>+ new\n<<default>>'#
header_base = '\n<<lightpurple>>{0:*^50}<<default>>\n'#
headers = ['  ALL CHANGES  ', '  REVIEW CHANGES  ', '  APPROVED CHANGES  ']#
newtext = 'new'#
none_message = '<<lightpurple>>                      None.                       <<default>>'#
oldtext = 'old'#
test_accept(input, mock)[source]#

Check output of cherry_pick if changes accepted.

test_by_letter_accept(input, mock)[source]#

Check cherry_pick output.

If by_letter diff is enabled and changes accepted.

test_by_letter_quit(input, mock)[source]#

Check cherry_pick output.

If by_letter diff is enabled and quit during review.

test_quit(input, mock)[source]#

Check output of cherry_pick if quit.

test_reject(input, mock)[source]#

Check output of cherry_pick if changes rejected.

class tests.diff_tests.TestDryHTMLComparator(*args, **kwargs)[source]#

Bases: DisableSiteMixin, TestCase

Test html_comparator method with given strings as test cases.

abstract_class = False#
test_added_context()[source]#

Test html_comparator’s detection of added-context.

test_deleted_context()[source]#

Test html_comparator’s detection of deleted-context.

test_run()[source]#

Test html_comparator using examples given in mw-api docs.

class tests.diff_tests.TestHTMLComparator(*args, **kwargs)[source]#

Bases: CheckHostnameMixin, TestCase

Test html_comparator using api.php in en:wiki.

abstract_class = False#
code = 'en'#
family = 'wikipedia'#
net = True#
site = True#
sites = {'wikipedia:en': {'code': 'en', 'family': 'wikipedia'}}#
test_wikipedia_rev_139992()[source]#

Test html_comparator with revision 139992 in en:wikipedia.

class tests.diff_tests.TestNoBeautifulSoup(*args, **kwargs)[source]#

Bases: DisableSiteMixin, TestCase

Test functions when BeautifulSoup is not installed.

abstract_class = False#
test_html_comparator(mocked_import)[source]#

Test html_comparator when bs4 not installed.

class tests.diff_tests.TestPatchManager(*args, **kwargs)[source]#

Bases: DisableSiteMixin, TestCase

Test PatchManager class with given strings as test cases.

abstract_class = False#
cases = [(' test', '_test', {0: '@@ -1 +1 @@\n\n-  test\n? ^\n+ _test\n? ^\n'}), ('The quick brown fox jumps over the lazy dog.', 'quick brown dog jumps quickly over the lazy fox.', {0: '@@ -1 +1 @@\n\n- The quick brown fox jumps over the lazy dog.\n? ----            ^ ^                     ^ ^\n+ quick brown dog jumps quickly over the lazy fox.\n?             ^ ^       ++++++++              ^ ^\n'}), ('spam', 'eggs', {0: '@@ -1 +1 @@\n\n- spam\n+ eggs\n'}), ('Lorem\nipsum\ndolor', 'Quorem\nipsum\ndolom', {0: '@@ -1 +1 @@\n\n- Lorem\n? ^\n+ Quorem\n? ^^\n', 1: '@@ -3 +3 @@\n\n- dolor\n?     ^\n+ dolom\n?     ^\n'}), ('.foola.Pywikipediabot', '.foo.Pywikipediabot.foo.', {0: '@@ -1 +1 @@\n\n- .foola.Pywikipediabot\n?     --\n+ .foo.Pywikipediabot.foo.\n?                    +++++\n'}), ('{foola}Pywikipediabot', '{foo}Pywikipediabot{foo}', {0: '@@ -1 +1 @@\n\n- {foola}Pywikipediabot\n?     --\n+ {foo}Pywikipediabot{foo}\n?                    +++++\n'}), ('{default}Foo bar Pywikipediabot foo bar', '{default}Foo  bar  Pywikipediabot  foo  bar', {0: '@@ -1 +1 @@\n\n- {default}Foo bar Pywikipediabot foo bar\n+ {default}Foo  bar  Pywikipediabot  foo  bar\n?              +   +                +    +\n'}), ('Pywikipediabot foo', 'Pywikipediabot  foo', {0: '@@ -1 +1 @@\n\n- Pywikipediabot foo\n+ Pywikipediabot  foo\n?                +\n'}), ('  Pywikipediabot    ', '   Pywikipediabot   ', {0: '@@ -1 +1 @@\n\n-   Pywikipediabot    \n?                    -\n+    Pywikipediabot   \n? +\n'})]#
test_patch_manager()[source]#

Test PatchManager.

test_patch_manager_no_diff()[source]#

Test PatchManager for the same strings.