@@ -880,13 +880,13 @@ def testGuiEditor_TextManipulation(qtbot, nwGUI, projPath, ipsumText, mockRnd):
880
880
# Wrap Equal
881
881
nwGUI .docEditor .replaceText (text )
882
882
nwGUI .docEditor .setCursorPosition (45 )
883
- assert nwGUI .docEditor ._wrapSelection ("=" ) is True
883
+ nwGUI .docEditor ._wrapSelection ("=" )
884
884
assert nwGUI .docEditor .getText () == text .replace ("consectetur" , "=consectetur=" )
885
885
886
886
# Wrap Unequal
887
887
nwGUI .docEditor .replaceText (text )
888
888
nwGUI .docEditor .setCursorPosition (45 )
889
- assert nwGUI .docEditor ._wrapSelection ("=" , "*" ) is True
889
+ nwGUI .docEditor ._wrapSelection ("=" , "*" )
890
890
assert nwGUI .docEditor .getText () == text .replace ("consectetur" , "=consectetur*" )
891
891
892
892
# Past Paragraph
@@ -895,7 +895,7 @@ def testGuiEditor_TextManipulation(qtbot, nwGUI, projPath, ipsumText, mockRnd):
895
895
cursor .setPosition (13 , QTextCursor .MoveAnchor )
896
896
cursor .setPosition (1000 , QTextCursor .KeepAnchor )
897
897
nwGUI .docEditor .setTextCursor (cursor )
898
- assert nwGUI .docEditor ._wrapSelection ("=" ) is True
898
+ nwGUI .docEditor ._wrapSelection ("=" )
899
899
900
900
newText = nwGUI .docEditor .getText ()
901
901
newPara = list (filter (str .strip , newText .split ("\n " )))
@@ -910,14 +910,15 @@ def testGuiEditor_TextManipulation(qtbot, nwGUI, projPath, ipsumText, mockRnd):
910
910
# Block format repetition
911
911
nwGUI .docEditor .replaceText (text )
912
912
nwGUI .docEditor .setCursorPosition (39 )
913
- assert nwGUI .docEditor ._toggleFormat (1 , "=" ) is True
913
+ nwGUI .docEditor ._toggleFormat (1 , "=" )
914
+ assert nwGUI .docEditor .getText () == text .replace ("amet" , "=amet=" , 1 )
915
+ nwGUI .docEditor ._toggleFormat (1 , "=" )
914
916
assert nwGUI .docEditor .getText () == text .replace ("amet" , "=amet=" , 1 )
915
- assert nwGUI .docEditor ._toggleFormat (1 , "=" ) is False
916
917
917
918
# Wrap Single Equal
918
919
nwGUI .docEditor .replaceText (text )
919
920
nwGUI .docEditor .setCursorPosition (45 )
920
- assert nwGUI .docEditor ._toggleFormat (1 , "=" ) is True
921
+ nwGUI .docEditor ._toggleFormat (1 , "=" )
921
922
assert nwGUI .docEditor .getText () == text .replace ("consectetur" , "=consectetur=" )
922
923
923
924
# Past Paragraph
@@ -926,7 +927,7 @@ def testGuiEditor_TextManipulation(qtbot, nwGUI, projPath, ipsumText, mockRnd):
926
927
cursor .setPosition (13 , QTextCursor .MoveAnchor )
927
928
cursor .setPosition (1000 , QTextCursor .KeepAnchor )
928
929
nwGUI .docEditor .setTextCursor (cursor )
929
- assert nwGUI .docEditor ._toggleFormat (1 , "=" ) is True
930
+ nwGUI .docEditor ._toggleFormat (1 , "=" )
930
931
931
932
newText = nwGUI .docEditor .getText ()
932
933
newPara = list (filter (str .strip , newText .split ("\n " )))
@@ -936,30 +937,40 @@ def testGuiEditor_TextManipulation(qtbot, nwGUI, projPath, ipsumText, mockRnd):
936
937
# Wrap Double Equal
937
938
nwGUI .docEditor .replaceText (text )
938
939
nwGUI .docEditor .setCursorPosition (45 )
939
- assert nwGUI .docEditor ._toggleFormat (2 , "=" ) is True
940
+ nwGUI .docEditor ._toggleFormat (2 , "=" )
941
+ assert nwGUI .docEditor .getText () == text .replace ("consectetur" , "==consectetur==" )
942
+
943
+ # Toggle Double Equal with Selection
944
+ nwGUI .docEditor .replaceText (text )
945
+ nwGUI .docEditor .setCursorSelection (41 , 11 )
946
+ nwGUI .docEditor ._toggleFormat (2 , "=" )
940
947
assert nwGUI .docEditor .getText () == text .replace ("consectetur" , "==consectetur==" )
948
+ assert nwGUI .docEditor .getSelectedText () == "consectetur"
949
+ nwGUI .docEditor ._toggleFormat (2 , "=" )
950
+ assert nwGUI .docEditor .getText () == text
951
+ assert nwGUI .docEditor .getSelectedText () == "consectetur"
941
952
942
953
# Toggle Double Equal
943
954
nwGUI .docEditor .replaceText (text )
944
955
nwGUI .docEditor .setCursorPosition (45 )
945
- assert nwGUI .docEditor ._toggleFormat (2 , "=" ) is True
946
- assert nwGUI .docEditor ._toggleFormat (2 , "=" ) is True
956
+ nwGUI .docEditor ._toggleFormat (2 , "=" )
957
+ nwGUI .docEditor ._toggleFormat (2 , "=" )
947
958
assert nwGUI .docEditor .getText () == text
948
959
949
960
# Toggle Triple+Double Equal
950
961
nwGUI .docEditor .replaceText (text )
951
962
nwGUI .docEditor .setCursorPosition (45 )
952
- assert nwGUI .docEditor ._toggleFormat (3 , "=" ) is True
953
- assert nwGUI .docEditor ._toggleFormat (2 , "=" ) is True
963
+ nwGUI .docEditor ._toggleFormat (3 , "=" )
964
+ nwGUI .docEditor ._toggleFormat (2 , "=" )
954
965
assert nwGUI .docEditor .getText () == text .replace ("consectetur" , "=consectetur=" )
955
966
956
967
# Toggle Unequal
957
968
repText = text .replace ("consectetur" , "=consectetur==" )
958
969
nwGUI .docEditor .replaceText (repText )
959
970
nwGUI .docEditor .setCursorPosition (45 )
960
- assert nwGUI .docEditor ._toggleFormat (1 , "=" ) is True
971
+ nwGUI .docEditor ._toggleFormat (1 , "=" )
961
972
assert nwGUI .docEditor .getText () == text .replace ("consectetur" , "consectetur=" )
962
- assert nwGUI .docEditor ._toggleFormat (1 , "=" ) is True
973
+ nwGUI .docEditor ._toggleFormat (1 , "=" )
963
974
assert nwGUI .docEditor .getText () == repText
964
975
965
976
# Replace Quotes
@@ -969,15 +980,16 @@ def testGuiEditor_TextManipulation(qtbot, nwGUI, projPath, ipsumText, mockRnd):
969
980
text = "### A Scene\n \n %s" % ipsumText [0 ].replace ("consectetur" , "=consectetur=" )
970
981
nwGUI .docEditor .replaceText (text )
971
982
nwGUI .docEditor .setCursorPosition (45 )
972
- assert nwGUI .docEditor ._replaceQuotes ("=" , "<" , ">" ) is False
983
+ nwGUI .docEditor ._replaceQuotes ("=" , "<" , ">" )
984
+ assert nwGUI .docEditor .getText () == text
973
985
974
986
# First Paragraph Selected
975
987
# This should not replace anything in second paragraph
976
988
text = "### A Scene\n \n %s" % "\n \n " .join (ipsumText [0 :2 ]).replace ("ipsum" , "=ipsum=" )
977
989
nwGUI .docEditor .replaceText (text )
978
990
nwGUI .docEditor .setCursorPosition (45 )
979
991
assert nwGUI .docEditor .docAction (nwDocAction .SEL_PARA )
980
- assert nwGUI .docEditor ._replaceQuotes ("=" , "<" , ">" ) is True
992
+ nwGUI .docEditor ._replaceQuotes ("=" , "<" , ">" )
981
993
982
994
newText = nwGUI .docEditor .getText ()
983
995
newPara = list (filter (str .strip , newText .split ("\n " )))
@@ -989,7 +1001,7 @@ def testGuiEditor_TextManipulation(qtbot, nwGUI, projPath, ipsumText, mockRnd):
989
1001
nwGUI .docEditor .replaceText (text )
990
1002
nwGUI .docEditor .setCursorPosition (45 )
991
1003
assert nwGUI .docEditor .docAction (nwDocAction .SEL_ALL )
992
- assert nwGUI .docEditor ._replaceQuotes ("=" , "<" , ">" ) is True
1004
+ nwGUI .docEditor ._replaceQuotes ("=" , "<" , ">" )
993
1005
assert nwGUI .docEditor .getText () == text .replace ("=Lorem=" , "<Lorem>" )
994
1006
995
1007
# Remove Line Breaks
0 commit comments