Skip to content

Commit e3931b6

Browse files
authored
Merge pull request #133 from Ekopalypse/AdaptTestsToSci420
Adapt tests to sci420
2 parents 941183b + 4b3fab1 commit e3931b6

File tree

4 files changed

+18
-11
lines changed

4 files changed

+18
-11
lines changed

PythonScript/python_tests/tests/NotepadWrapperTestCase.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from threading import Timer
1111
import subprocess
1212

13-
from Npp import *
13+
from Npp import notepad, editor, console, WINVER, LANGTYPE, MENUCOMMAND, BUFFERENCODING
1414

1515
EnumWindowsProc = ctypes.WINFUNCTYPE(ctypes.c_bool,
1616
ctypes.wintypes.HWND,
@@ -193,7 +193,7 @@ def test_saveAsCopy(self):
193193
copyFilename = self.get_temp_filename()
194194
notepad.saveAs(realFilename)
195195
notepad.saveAsCopy(copyFilename)
196-
editor.write('-OriginalChanged')
196+
editor.appendText('-OriginalChanged')
197197
notepad.save()
198198
notepad.close()
199199
self.check_file_contents(realFilename, 'Hello world - saveAsCopy-OriginalChanged')
@@ -693,7 +693,7 @@ def test_getAppdataPluginsAllowed(self):
693693
npp_dir = notepad.getNppDir()
694694
appdata_plugins_allowed_file = os.path.join(npp_dir, 'allowAppDataPlugins.xml')
695695
appdata_plugins_allowed = os.path.exists(appdata_plugins_allowed_file)
696-
do_local_conf_file = os.path.join(npp_dir, 'doLocalConf.xml')
696+
_ = os.path.join(npp_dir, 'doLocalConf.xml')
697697
do_local_conf = os.path.exists(appdata_plugins_allowed_file)
698698

699699
if appdata_plugins_allowed and do_local_conf:
@@ -854,9 +854,13 @@ def test_getNbUserLang(self):
854854
self.__test_invalid_parameter_passed(notepad.getNbUserLang)
855855
number_of_udls = notepad.getNbUserLang()
856856
userdefined_xml_file = os.path.join(self._get_config_directory(), r'userDefineLang.xml')
857+
userdefined_xml_path = os.path.join(self._get_config_directory(), r'userDefineLangs')
858+
number_of_user_langs_from_xml = 0
857859
if os.path.exists(userdefined_xml_file):
858860
udl_doc = et.parse(userdefined_xml_file)
859-
number_of_user_langs_from_xml = len(udl_doc.findall('UserLang'))
861+
number_of_user_langs_from_xml += len(udl_doc.findall('UserLang'))
862+
if os.path.exists(userdefined_xml_path):
863+
number_of_user_langs_from_xml += len([x for x in os.listdir(userdefined_xml_path) if x.endswith('.xml')])
860864
else:
861865
number_of_user_langs_from_xml = 0
862866
self.assertIsInstance(number_of_udls, int)

PythonScript/python_tests/tests/ReplaceAnsiPythonFunction.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22
import unittest
3-
from Npp import *
3+
from Npp import notepad, editor
44

55
counter = 0
66

@@ -26,7 +26,7 @@ def setUp(self):
2626
global counter
2727
counter = 0
2828
notepad.new()
29-
notepad.runMenuCommand("Encoding", "Encode in ANSI")
29+
notepad.runMenuCommand("Encoding", "Convert to ANSI")
3030
editor.write(u'abc123 def5432 gh98\r\näbc123 üef5432 öh98\r\n'.encode('windows-1252'))
3131

3232
def tearDown(self):

PythonScript/python_tests/tests/ReplaceAnsiTestCase.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# -*- coding: utf-8 -*-
22
import unittest
3-
from Npp import *
3+
from Npp import notepad, editor
44

55
class ReplaceAnsiTestCase(unittest.TestCase):
66
def setUp(self):
77
notepad.new()
8-
notepad.runMenuCommand("Encoding", "Encode in ANSI")
8+
notepad.runMenuCommand("Encoding", "Convert to ANSI")
99
editor.write(u'Here is some text\r\nWith some umlauts XäXüXö\r\n'.encode('windows-1252'));
1010

1111
def tearDown(self):

PythonScript/python_tests/tests/ScintillaWrapperTestCase.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
import unittest
33
import time
44

5-
from Npp import *
5+
from Npp import (
6+
editor, notepad, SCINTILLANOTIFICATION, FINDOPTION, KEYMOD,
7+
SCINTILLAMESSAGE, LEXER, MODIFICATIONFLAGS, LANGTYPE, Cell
8+
)
69

710

811
class ScintillaWrapperTestCase(unittest.TestCase):
@@ -801,7 +804,7 @@ def test_scintillawrapper_colour_int_void_in_callback(self):
801804
self.assertEqual(self.callbackCalled, True)
802805

803806
def test_scintillawrapper_bool_int_void(self):
804-
original = editor.getMarginSensitiveN(1)
807+
_ = editor.getMarginSensitiveN(1)
805808
editor.setMarginSensitiveN(1, True)
806809
shouldBeTrue = editor.getMarginSensitiveN(1)
807810
editor.setMarginSensitiveN(1, False)
@@ -820,7 +823,7 @@ def test_scintillawrapper_bool_int_void_in_callback(self):
820823
self.assertEqual(self.callbackCalled, True)
821824

822825
def test_scintillawrapper_void_void_string_lexerLanguage(self):
823-
original = editor.getLexerLanguage()
826+
_ = editor.getLexerLanguage()
824827
editor.setLexerLanguage('python')
825828
python = editor.getLexerLanguage()
826829
self.assertEqual(python, 'python')

0 commit comments

Comments
 (0)