Skip to content

Commit 99243a6

Browse files
committed
- fixed string length in extractEncodedString()
- removed commented deprecated code: pyreplace, pymlreplace, pysearch, pymlsearch - adapted further unittest cases - adpated code indentation
1 parent 9186f6c commit 99243a6

File tree

7 files changed

+14
-554
lines changed

7 files changed

+14
-554
lines changed

PythonScript/python_tests/tests/ConsoleTestCase.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def test_print_utf8_to_console(self):
1313
console.clear()
1414
console.write(u'\u00C4pfel')
1515
text = console.editor.getText()
16-
self.assertEqual(text, u'\u00C4pfel'.encode('utf-8'))
16+
self.assertEqual(text, u'\u00C4pfel')
1717
console.clear()
1818

1919

PythonScript/python_tests/tests/NotepadWrapperTestCase.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,17 @@ def tearDown(self):
3737
def normalise_filename(self, filename):
3838
buf = ctypes.create_unicode_buffer(260)
3939
GetLongPathName = ctypes.windll.kernel32.GetLongPathNameW
40-
GetLongPathName(filename.decode('windows-1252'), buf, 260)
40+
# TODO: replaced filename.decode('windows-1252') by just filename,
41+
# TODO: what is ok on win10, might be a problem on older windows versions
42+
GetLongPathName(filename, buf, 260)
4143
return buf.value.lower()
4244

4345

4446
def check_file_contents(self, filename, expectedContents):
4547
f = open(filename, "rb")
4648
actualContents = f.read()
4749
f.close()
48-
self.assertEqual(actualContents, expectedContents)
50+
self.assertEqual(actualContents.decode('utf-8'), expectedContents)
4951

5052

5153
def get_temp_filename(self):
@@ -1268,11 +1270,13 @@ def test_saveFile(self):
12681270
self.assertEqual(_content, '')
12691271

12701272
notepad.saveFile(tmpfile)
1273+
# TODO moved here from below, because otherwise with N++ 7.8.6 the _content is still empty
1274+
# TODO on reading below from python/filesystem, seems to be a N++ issue, which needs further investigation
1275+
notepad.close()
12711276
with open(tmpfile, 'r') as f:
12721277
_content = f.read()
12731278

12741279
self.assertEqual(_content, text_to_be_saved)
1275-
notepad.close()
12761280

12771281

12781282
def test_setEditorBorderEdge(self):

PythonScript/python_tests/tests/ScintillaWrapperTestCase.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,7 @@ def test_scintillawrapper_void_void_string_in_callback_lexerLanguage(self):
839839
self.assertEqual(self.callbackCalled, True)
840840

841841
def test_scintillawrapper_void_void_string(self):
842+
editor.setWordChars('dummy_input')
842843
originalWordChars = editor.getWordChars()
843844
editor.setWordChars('abcdefghijklmnop')
844845
changedWordChars = editor.getWordChars()

PythonScript/src/NotepadPlusWrapper.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ idx_t NotepadPlusWrapper::getCurrentDocIndex(int view)
435435
void NotepadPlusWrapper::setStatusBar(StatusBarSection section, const char *text)
436436
{
437437
#ifdef UNICODE
438-
std::shared_ptr<TCHAR> s = WcharMbcsConverter::char2tchar(text);
438+
std::shared_ptr<TCHAR> s = WcharMbcsConverter::char2tchar(text);
439439
callNotepad(NPPM_SETSTATUSBAR, static_cast<WPARAM>(section), reinterpret_cast<LPARAM>(s.get()));
440440
#else
441441
callNotepad(NPPM_SETSTATUSBAR, static_cast<WPARAM>(section), reinterpret_cast<LPARAM>(text));
@@ -471,7 +471,7 @@ void NotepadPlusWrapper::activateFileString(boost::python::str filename)
471471
{
472472
notAllowedInScintillaCallback("activateFile() cannot be called in a synchronous editor callback. "
473473
"Use an asynchronous callback, or avoid using activateFile() in the callback handler");
474-
#ifdef UNICODE
474+
#ifdef UNICODE
475475
std::shared_ptr<TCHAR> s = WcharMbcsConverter::char2tchar((const char*)boost::python::extract<const char*>(filename));
476476
callNotepad(NPPM_SWITCHTOFILE, 0, reinterpret_cast<LPARAM>(s.get()));
477477
#else

PythonScript/src/ScintillaPython.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,6 @@ BOOST_PYTHON_MODULE(Npp)
8989
" def myIncrement(m):\n"
9090
" return int(m.group(1)) + 1\n\n"
9191
"And call rereplace('([0-9]+)', myIncrement) and it will increment all the integers.")
92-
.def("pyreplace", boost::python::raw_function(&deprecated_replace_function), "Deprecated in this version of PythonScript for Notepad++. Use the new rereplace() instead")
93-
.def("pymlreplace", boost::python::raw_function(&deprecated_replace_function), "Deprecated in this version of PythonScript for Notepad++. Use the new rereplace() instead")
9492
.def("getWord", &ScintillaWrapper::getWord, "getWord([position[, useOnlyWordChars]])\nGets the word at position. If position is not given or None, the current caret position is used.\nuseOnlyWordChars is a bool that is passed to Scintilla - see Scintilla rules on what is match. If not given or None, it is assumed to be true.")
9593
.def("getWord", &ScintillaWrapper::getWordNoFlags, "getWord([position[, useOnlyWordChars]])\nGets the word at position. If position is not given or None, the current caret position is used.\nuseOnlyWordChars is a bool that is passed to Scintilla - see Scintilla rules on what is match. If not given or None, it is assumed to be true.")
9694
.def("getWord", &ScintillaWrapper::getCurrentWord, "getWord([position[, useOnlyWordChars]])\nGets the word at position. If position is not given or None, the current caret position is used.\nuseOnlyWordChars is a bool that is passed to Scintilla - see Scintilla rules on what is match. If not given or None, it is assumed to be true.")

0 commit comments

Comments
 (0)