1- # -*- coding: utf-8 -*-
1+ # -*- coding: utf-8 -*-
22import unittest
33from Npp import notepad , editor
44
@@ -19,7 +19,7 @@ def group1_with_counter(m):
1919
2020
2121
22-
22+
2323
2424class ReplaceAnsiPythonFunctionTestCase (unittest .TestCase ):
2525 def setUp (self ):
@@ -28,25 +28,25 @@ def setUp(self):
2828 notepad .new ()
2929 notepad .runMenuCommand ("Encoding" , "Convert to ANSI" )
3030 editor .write (u'abc123 def5432 gh98\r \n äbc123 üef5432 öh98\r \n ' .encode ('windows-1252' ))
31-
31+
3232 def tearDown (self ):
3333 editor .setSavePoint ()
3434 notepad .close ()
35-
35+
3636 def test_replace_function (self ):
3737 editor .rereplace (r'([a-z]+)([0-9]+)' .encode ('windows-1252' ), group2_with_counter )
3838 text = editor .getText ()
3939 self .assertEqual (text , u'1231 54322 983\r \n ä1234 ü54325 ö986\r \n ' .encode ('windows-1252' ))
40-
40+
4141 def test_unicode_replace_function (self ):
4242 editor .rereplace (ur'([a-zäöü]+)([0-9]+)' , group1_with_counter )
4343 text = editor .getText ()
4444 self .assertEqual (text , u'abc1 def2 gh3\r \n äbc4 üef5 öh6\r \n ' .encode ('windows-1252' ))
45-
45+
4646 def groups_check (self , m ):
4747 global counter
4848 counter += 1
49- groups_data_correct = { 1 : ('abc' , '123' ),
49+ groups_data_correct = { 1 : ('abc' , '123' ),
5050 2 : ('def' , '5432' ),
5151 3 : ('gh' , '98' ),
5252 4 : (u'äbc' .encode ('windows-1252' ), '123' ),
@@ -80,15 +80,15 @@ def test_named_groups_2(self):
8080 def group_tuples_check (self , m ):
8181 global counter
8282 counter += 1
83- groups_data_correct = { 1 : ('123' , 'abc' , '123' ),
83+ groups_data_correct = { 1 : ('123' , 'abc' , '123' ),
8484 2 : ('5432' , 'def' , '5432' ),
8585 3 : ('98' , 'gh' , '98' ),
8686 4 : ('123' , '\xe4 bc' , '123' ),
8787 5 : ('5432' , u'üef' .encode ('windows-1252' ), '5432' ),
8888 6 : ('98' , u'öh' .encode ('windows-1252' ), '98' ) }
8989 self .assertEqual (m .group (2 , 'letters' , 'numbers' ), groups_data_correct [counter ])
9090 return counter
91-
91+
9292 def test_group_tuples (self ):
9393 editor .rereplace (ur'(?<letters>[a-zäöü]+)(?<numbers>[0-9]+)' , lambda m : self .group_tuples_check (m ))
9494 text = editor .getText ()
0 commit comments