@@ -46,7 +46,7 @@ def test_BuildError(self):
46
46
assert e .command == "c"
47
47
48
48
try :
49
- raise SCons .Errors .BuildError ("n" , "foo" , 57 , 3 , "file" ,
49
+ raise SCons .Errors .BuildError ("n" , "foo" , 57 , 3 , "file" ,
50
50
"e" , "a" , "c" , (1 ,2 ,3 ))
51
51
except SCons .Errors .BuildError as e :
52
52
assert e .errstr == "foo" , e .errstr
@@ -96,26 +96,48 @@ def test_ExplicitExit(self):
96
96
assert e .node == "node"
97
97
98
98
def test_convert_EnvironmentError_to_BuildError (self ) -> None :
99
- """Test the convert_to_BuildError function on SConsEnvironmentError
100
- exceptions.
101
- """
99
+ """Test convert_to_BuildError on SConsEnvironmentError."""
102
100
ee = SCons .Errors .SConsEnvironmentError ("test env error" )
103
101
be = SCons .Errors .convert_to_BuildError (ee )
104
- assert be .errstr == "test env error"
105
- assert be .status == 2
106
- assert be .exitstatus == 2
107
- assert be .filename is None
102
+ with self .subTest ():
103
+ self .assertEqual (be .errstr , "test env error" )
104
+ with self .subTest ():
105
+ self .assertEqual (be .status , 2 )
106
+ with self .subTest ():
107
+ self .assertEqual (be .exitstatus , 2 )
108
+ with self .subTest ():
109
+ self .assertIsNone (be .filename )
108
110
109
111
def test_convert_OSError_to_BuildError (self ) -> None :
110
- """Test the convert_to_BuildError function on OSError
111
- exceptions.
112
- """
112
+ """Test convert_to_BuildError on OSError."""
113
113
ose = OSError (7 , 'test oserror' )
114
114
be = SCons .Errors .convert_to_BuildError (ose )
115
- assert be .errstr == 'test oserror'
116
- assert be .status == 7
117
- assert be .exitstatus == 2
118
- assert be .filename is None
115
+ with self .subTest ():
116
+ self .assertEqual (be .errstr , 'test oserror' )
117
+ with self .subTest ():
118
+ self .assertEqual (be .status , 7 )
119
+ with self .subTest ():
120
+ self .assertEqual (be .exitstatus , 2 )
121
+ with self .subTest ():
122
+ self .assertIsNone (be .filename )
123
+
124
+ def test_convert_phony_OSError_to_BuildError (self ) -> None :
125
+ """Test convert_to_BuildError on OSError with defaults."""
126
+ class PhonyException (OSError ):
127
+ def __init__ (self , name ):
128
+ OSError .__init__ (self , name ) # most fields will default to None
129
+ self .name = name
130
+
131
+ ose = PhonyException ("test oserror" )
132
+ be = SCons .Errors .convert_to_BuildError (ose )
133
+ with self .subTest ():
134
+ self .assertEqual (be .errstr , 'test oserror' )
135
+ with self .subTest ():
136
+ self .assertEqual (be .status , 2 )
137
+ with self .subTest ():
138
+ self .assertEqual (be .exitstatus , 2 )
139
+ with self .subTest ():
140
+ self .assertIsNone (be .filename )
119
141
120
142
121
143
if __name__ == "__main__" :
0 commit comments