Skip to content

Commit 3ca27bb

Browse files
authored
Use self.fail instead of Fail (#2060)
1 parent 05741af commit 3ca27bb

13 files changed

Lines changed: 39 additions & 40 deletions

File tree

tests/IronPython.Tests/Cases/IronPythonCasesManifest.ini

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,6 @@ NotParallelSafe=true # Uses a temporary module with a fixed name
193193
[IronPython.modules.misc.test__weakref]
194194
RetryCount=2
195195

196-
[IronPython.modules.misc.test_zlib]
197-
198196
[IronPython.modules.system_related.test_nt]
199197
RunCondition=NOT $(IS_POSIX)
200198
NotParallelSafe=true # Uses fixed file, directory, and environment variable names

tests/suite/interop/net/field/test_field_misc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ def test_accessibility(self):
2525
self.assertIn('ProtectedField', dir(o))
2626
with self.assertRaises(TypeError):
2727
hasattr(o, 'ProtectedField')
28-
self.assertRaisesRegexp(AttributeError, "'Misc' object has no attribute 'PrivateField'", lambda: o.PrivateField)
28+
self.assertRaisesRegex(AttributeError, "'Misc' object has no attribute 'PrivateField'", lambda: o.PrivateField)
2929
self.assertEqual(o.InterfaceField.PublicStaticField, 500)
30-
30+
3131
o = DerivedMisc()
3232
o.Set()
3333
self.assertEqual(o.PublicField, 400)

tests/suite/interop/net/type/test___clrtype.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ class X(object, metaclass=MyType):
529529
#Shouldn't be able to use non-UInt64s
530530
try:
531531
x.NOT_SO_DYNAMIC = "0"
532-
Fail("TypeError should have been thrown!")
532+
self.fail("TypeError should have been thrown!")
533533
except TypeError as e:
534534
self.assertEqual(str(e),
535535
"expected UInt64, got str")
@@ -710,7 +710,7 @@ def __clrtype__(self, stuff):
710710
try:
711711
class X(object, metaclass=MyType):
712712
pass
713-
Fail("Bad __clrtype__ signature!")
713+
self.fail("Bad __clrtype__ signature!")
714714

715715
except TypeError as e:
716716
self.assertEqual(str(e),
@@ -748,7 +748,7 @@ def __clrtype__(self):
748748
try:
749749
class X(object, metaclass=MyType):
750750
pass
751-
Fail("Arbitrary return values of __clrtype__ should not be allowed: " + str(x))
751+
self.fail("Arbitrary return values of __clrtype__ should not be allowed: " + str(x))
752752
except TypeError as e:
753753
self.assertEqual(str(e),
754754
expected_msg)
@@ -768,7 +768,7 @@ def __clrtype__(self):
768768
try:
769769
class X(object, metaclass=MyType):
770770
pass
771-
Fail("Arbitrary return values of __clrtype__ are not allowed: ", + str(x))
771+
self.fail("Arbitrary return values of __clrtype__ are not allowed: ", + str(x))
772772
except ValueError as e:
773773
self.assertEqual(str(e), "__clrtype__ must return a type, not None")
774774
finally:

tests/suite/modules/io_related/test_cPickle.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,7 @@ def test_cp945(self):
718718
#--sanity
719719
try:
720720
x = 1/0
721-
Fail("should have been division by zero error")
721+
self.fail("should have been division by zero error")
722722
except Exception as e:
723723
ex = e
724724

tests/suite/modules/io_related/test_copyreg.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,11 @@ def test_extension_cache(self):
173173
"The get and set of the attribute failed")
174174

175175
if 'cache1' not in copyreg._extension_cache or 'cache2' not in copyreg._extension_cache:
176-
Fail("Set of the attribute failed")
176+
self.fail("Set of the attribute failed")
177177

178178
copyreg.clear_extension_cache()
179179
if 'cache1' in copyreg._extension_cache or 'cache2' in copyreg._extension_cache:
180-
Fail("The method clear_extension_cache did not work correctly ")
180+
self.fail("The method clear_extension_cache did not work correctly ")
181181

182182
def test_reconstructor(self):
183183
reconstructor_copy = copyreg._reconstructor

tests/suite/modules/misc/test_operator.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import operator
66
import unittest
7+
import sys
78

89
from iptest import IronPythonTestCase, is_cli, is_netcoreapp, big, run_test, skipUnlessIronPython
910

@@ -276,7 +277,7 @@ def pow(a,b): return a ** b
276277
r = fnc(a,b)
277278
except:
278279
(exc_type, exc_value, exc_traceback) = sys.exc_info()
279-
Fail("Binary operator failed: %s, %s: %s %s %s (Message=%s)" % (type(a).__name__, type(b).__name__, str(a), sym, str(b), str(exc_value)))
280+
self.fail("Binary operator failed: %s, %s: %s %s %s (Message=%s)" % (type(a).__name__, type(b).__name__, str(a), sym, str(b), str(exc_value)))
280281

281282
threes = [ 3, big(3), 3.0 ]
282283
zeroes = [ 0, big(0), 0.0 ]
@@ -294,7 +295,7 @@ def pow(a,b): return a ** b
294295
pass
295296
else:
296297
(exc_type, exc_value, exc_traceback) = sys.exc_info()
297-
Fail("Didn't get ZeroDivisionError %s, %s, %s, %s, %s (Message=%s)" % (str(func), type(i).__name__, type(j).__name__, str(i), str(j), str(exc_value)))
298+
self.fail("Didn't get ZeroDivisionError %s, %s, %s, %s, %s (Message=%s)" % (str(func), type(i).__name__, type(j).__name__, str(i), str(j), str(exc_value)))
298299

299300
def test_unary_ops(self):
300301
if is_cli:

tests/suite/test_class.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2167,7 +2167,7 @@ def __getattr__(self, name): raise AttributeError('catch me')
21672167
y = x.throws
21682168
except AttributeError as ex:
21692169
self.assertEqual(ex.args, ('catch me',))
2170-
else: Fail("should have thrown")
2170+
else: self.fail("should have thrown")
21712171

21722172
def test_descriptor_meta_magic(self):
21732173
class valueDescriptor(object):

tests/suite/test_metaclass.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ class D(C): pass
133133
class D(C1, metaclass=dash_attributes):
134134
pass
135135
except TypeError: pass
136-
else: Fail("metaclass conflict expected")
136+
else: self.fail("metaclass conflict expected")
137137

138138
class D(C2, metaclass=dash_attributes):
139139
def StartSomethingToday(self): pass

tests/suite/test_python26.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ def test_pep3110(self):
645645
try:
646646
raise IOError("abc")
647647
except TypeError as ValueError:
648-
Fail("IOError is not the same as TypeError")
648+
self.fail("IOError is not the same as TypeError")
649649
except IOError:
650650
pass
651651
self.assertEqual(ValueError, orig_ValueError)
@@ -654,7 +654,7 @@ def test_pep3110(self):
654654
try:
655655
raise IOError("abc")
656656
except TypeError as ValueError:
657-
Fail("IOError is not the same as TypeError")
657+
self.fail("IOError is not the same as TypeError")
658658
finally:
659659
pass
660660
except IOError:
@@ -693,7 +693,7 @@ def test_pep3110(self):
693693
try:
694694
raise IOError("xyz")
695695
except (TypeError, ValueError) as e:
696-
Fail("IOError is not the same as TypeError or ValueError")
696+
self.fail("IOError is not the same as TypeError or ValueError")
697697
except IOError:
698698
pass
699699
self.assertEqual(e, None)
@@ -702,7 +702,7 @@ def test_pep3110(self):
702702
try:
703703
raise IOError("xyz")
704704
except (TypeError, ValueError) as e:
705-
Fail("IOError is not the same as TypeError or ValueError")
705+
self.fail("IOError is not the same as TypeError or ValueError")
706706
finally:
707707
pass
708708
except IOError:
@@ -745,31 +745,31 @@ def test_pep3110(self):
745745
try:
746746
raise IOError("abc")
747747
except TypeError as e:
748-
Fail("IOError is not the same as TypeError")
748+
self.fail("IOError is not the same as TypeError")
749749
except IOError as e:
750750
self.assertEqual(e.args[0], "abc")
751751
e = None
752752

753753
try:
754754
raise IOError("abc")
755755
except TypeError as e:
756-
Fail("IOError is not the same as TypeError")
756+
self.fail("IOError is not the same as TypeError")
757757
except IOError as e:
758758
self.assertEqual(e.args[0], "abc")
759759
e = None
760760

761761
try:
762762
raise IOError("abc")
763763
except TypeError as e:
764-
Fail("IOError is not the same as TypeError")
764+
self.fail("IOError is not the same as TypeError")
765765
except Exception as e:
766766
self.assertEqual(e.args[0], "abc")
767767
e = None
768768

769769
try:
770770
raise IOError("abc")
771771
except TypeError as e:
772-
Fail("IOError is not the same as TypeError")
772+
self.fail("IOError is not the same as TypeError")
773773
except:
774774
pass
775775

@@ -778,7 +778,7 @@ def test_pep3110(self):
778778
try:
779779
raise IOError("abc")
780780
except TypeError as e:
781-
Fail("IOError is not the same as TypeError")
781+
self.fail("IOError is not the same as TypeError")
782782
except IOError as e:
783783
self.assertEqual(e.args[0], "abc")
784784
e = None
@@ -787,7 +787,7 @@ def test_pep3110(self):
787787
try:
788788
raise IOError("abc")
789789
except TypeError as ValueError:
790-
Fail("IOError is not the same as TypeError")
790+
self.fail("IOError is not the same as TypeError")
791791
except IOError as e:
792792
self.assertEqual(e.args[0], "abc")
793793
e = None
@@ -796,7 +796,7 @@ def test_pep3110(self):
796796
try:
797797
raise IOError("abc")
798798
except TypeError as e:
799-
Fail("IOError is not the same as TypeError")
799+
self.fail("IOError is not the same as TypeError")
800800
except IOError as e:
801801
self.assertEqual(e.args[0], "abc")
802802
e = None
@@ -805,7 +805,7 @@ def test_pep3110(self):
805805
try:
806806
raise IOError("abc")
807807
except TypeError as ValueError:
808-
Fail("IOError is not the same as TypeError")
808+
self.fail("IOError is not the same as TypeError")
809809
finally:
810810
pass
811811
except Exception as e:
@@ -816,7 +816,7 @@ def test_pep3110(self):
816816
try:
817817
raise IOError("abc")
818818
except TypeError as e:
819-
Fail("IOError is not the same as TypeError")
819+
self.fail("IOError is not the same as TypeError")
820820
finally:
821821
pass
822822
except IOError:
@@ -964,14 +964,14 @@ def test_generatorexit(self):
964964
try:
965965
raise GeneratorExit()
966966
except Exception:
967-
Fail("Should not have caught this GeneratorExit")
967+
self.fail("Should not have caught this GeneratorExit")
968968
except GeneratorExit:
969969
pass
970970

971971
try:
972972
raise GeneratorExit()
973973
except Exception:
974-
Fail("Should not have caught this GeneratorExit")
974+
self.fail("Should not have caught this GeneratorExit")
975975
except GeneratorExit:
976976
pass
977977
finally:

tests/suite/test_regressions.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,26 +105,26 @@ def test_cp16831(self):
105105
temp.BProperty = True
106106
for i in range(2):
107107
if not temp.BProperty:
108-
Fail("Nullable Boolean was set to True")
108+
self.fail("Nullable Boolean was set to True")
109109
for i in range(2):
110110
if not temp.BProperty==True:
111-
Fail("Nullable Boolean was set to True")
111+
self.fail("Nullable Boolean was set to True")
112112

113113
temp.BProperty = False
114114
for i in range(2):
115115
if temp.BProperty:
116-
Fail("Nullable Boolean was set to False")
116+
self.fail("Nullable Boolean was set to False")
117117
for i in range(2):
118118
if not temp.BProperty==False:
119-
Fail("Nullable Boolean was set to False")
119+
self.fail("Nullable Boolean was set to False")
120120

121121
temp.BProperty = None
122122
for i in range(2):
123123
if temp.BProperty:
124-
Fail("Nullable Boolean was set to None")
124+
self.fail("Nullable Boolean was set to None")
125125
for i in range(2):
126126
if not temp.BProperty==None:
127-
Fail("Nullable Boolean was set to None")
127+
self.fail("Nullable Boolean was set to None")
128128

129129
def test_cp_27434(self):
130130
tests = {

0 commit comments

Comments
 (0)