|
3 | 3 | from Npp import * |
4 | 4 |
|
5 | 5 | class ReplaceUTF8TestCase(unittest.TestCase): |
6 | | - def setUp(self): |
7 | | - notepad.new() |
8 | | - notepad.runMenuCommand("Encoding", "Encode in UTF-8") |
9 | | - editor.write('Here is some text\r\nWith some umlauts XäXüXö\r\n'); |
10 | | - |
11 | | - def tearDown(self): |
12 | | - editor.setSavePoint() |
13 | | - notepad.close() |
14 | | - |
15 | | - def test_simple_replace(self): |
16 | | - editor.rereplace(r'some\s([a-z]+)', 'TEST'); |
17 | | - text = editor.getText() |
18 | | - self.assertEqual(text, 'Here is TEST\r\nWith TEST XäXüXö\r\n'); |
19 | | - |
20 | | - def test_utf8_replace(self): |
21 | | - editor.rereplace(r'X[äö]', 'YY'); |
22 | | - text = editor.getText() |
23 | | - self.assertEqual(text, 'Here is some text\r\nWith some umlauts YYXüYY\r\n'); |
24 | | - |
25 | | - |
| 6 | + def setUp(self): |
| 7 | + notepad.new() |
| 8 | + notepad.runMenuCommand("Encoding", "Encode in UTF-8") |
| 9 | + editor.write('Here is some text\r\nWith some umlauts XäXüXö\r\n'); |
| 10 | + |
| 11 | + def tearDown(self): |
| 12 | + editor.setSavePoint() |
| 13 | + notepad.close() |
| 14 | + |
| 15 | + def test_simple_replace(self): |
| 16 | + editor.rereplace(r'some\s([a-z]+)', 'TEST'); |
| 17 | + text = editor.getText() |
| 18 | + self.assertEqual(text, 'Here is TEST\r\nWith TEST XäXüXö\r\n'); |
| 19 | + |
| 20 | + def test_utf8_replace(self): |
| 21 | + editor.rereplace(r'X[äö]', 'YY'); |
| 22 | + text = editor.getText() |
| 23 | + self.assertEqual(text, 'Here is some text\r\nWith some umlauts YYXüYY\r\n'); |
| 24 | + |
| 25 | + def test_replace_condition(self): |
| 26 | + editor.rereplace('(Here)|(Xä)', '(?1Cheese)(?2Y)') |
| 27 | + text = editor.getText() |
| 28 | + self.assertEqual(text, 'Cheese is some text\r\nWith some umlauts YXüXö\r\n') |
26 | 29 | suite = unittest.TestLoader().loadTestsFromTestCase(ReplaceUTF8TestCase) |
0 commit comments