@@ -104,16 +104,30 @@ describe('Default IPython overrides', () => {
104
104
expect ( reverse ) . to . equal ( LINE_MAGIC_WITH_SPACE ) ;
105
105
} ) ;
106
106
107
- it ( 'overrides x =%ls' , ( ) => {
107
+ it ( 'overrides x =%ls and x = %ls ' , ( ) => {
108
108
// this is a corner-case as described in
109
109
// https://github.com/krassowski/jupyterlab-lsp/issues/281#issuecomment-645286076
110
110
let override = line_magics_map . override_for ( 'x =%ls' ) ;
111
111
expect ( override ) . to . equal ( 'x =get_ipython().run_line_magic("ls", "")' ) ;
112
+
113
+ override = line_magics_map . override_for ( 'x = %ls' ) ;
114
+ expect ( override ) . to . equal ( 'x = get_ipython().run_line_magic("ls", "")' ) ;
112
115
} ) ;
113
116
114
117
it ( 'does not override line-magic-like constructs' , ( ) => {
115
118
let override = line_magics_map . override_for ( 'list("%")' ) ;
116
119
expect ( override ) . to . equal ( null ) ;
120
+
121
+ override = line_magics_map . override_for ( 'list(" %test")' ) ;
122
+ expect ( override ) . to . equal ( null ) ;
123
+ } ) ;
124
+
125
+ it ( 'does not override modulo operators' , ( ) => {
126
+ let override = line_magics_map . override_for ( '3 % 2' ) ;
127
+ expect ( override ) . to . equal ( null ) ;
128
+
129
+ override = line_magics_map . override_for ( '3%2' ) ;
130
+ expect ( override ) . to . equal ( null ) ;
117
131
} ) ;
118
132
119
133
it ( 'escapes arguments' , ( ) => {
@@ -135,9 +149,22 @@ describe('Default IPython overrides', () => {
135
149
expect ( reverse ) . to . equal ( '!ls -o' ) ;
136
150
} ) ;
137
151
152
+ it ( 'overrides shell commands assignments: x =!ls and x = !ls' , ( ) => {
153
+ let override = line_magics_map . override_for ( 'x =!ls' ) ;
154
+ expect ( override ) . to . equal ( 'x =get_ipython().getoutput("ls")' ) ;
155
+
156
+ override = line_magics_map . override_for ( 'x = !ls' ) ;
157
+ expect ( override ) . to . equal ( 'x = get_ipython().getoutput("ls")' ) ;
158
+ } ) ;
159
+
138
160
it ( 'does not override shell-like constructs' , ( ) => {
139
161
let override = line_magics_map . override_for ( '"!ls"' ) ;
140
162
expect ( override ) . to . equal ( null ) ;
141
163
} ) ;
164
+
165
+ it ( 'does not override != comparisons' , ( ) => {
166
+ let override = line_magics_map . override_for ( '1 != None' ) ;
167
+ expect ( override ) . to . equal ( null ) ;
168
+ } )
142
169
} ) ;
143
170
} ) ;
0 commit comments