@@ -2245,17 +2245,24 @@ def func1(a, b, c):
2245
2245
# we need different expected results per version
2246
2246
# Note unlike the others, this result is a tuple, use assertIn
2247
2247
expected = {
2248
- (3 , 7 ): (bytearray (b' 3, 3, 0, 0,(),(),(|\x00 S\x00 ),(),()' ),),
2249
- (3 , 8 ): (bytearray (b' 3, 3, 0, 0,(),(),(|\x00 S\x00 ),(),()' ),),
2250
- (3 , 9 ): (bytearray (b' 3, 3, 0, 0,(),(),(|\x00 S\x00 ),(),()' ),),
2248
+ (3 , 7 ): (bytearray (b" 3, 3, 0, 0,(),(),(|\x00 S\x00 ),(),()" ),),
2249
+ (3 , 8 ): (bytearray (b" 3, 3, 0, 0,(),(),(|\x00 S\x00 ),(),()" ),),
2250
+ (3 , 9 ): (bytearray (b" 3, 3, 0, 0,(),(),(|\x00 S\x00 ),(),()" ),),
2251
2251
(3 , 10 ): ( # 3.10.1, 3.10.2
2252
- bytearray (b'3, 3, 0, 0,(N.),(),(|\x00 S\x00 ),(),()' ),
2253
- bytearray (b'3, 3, 0, 0,(),(),(|\x00 S\x00 ),(),()' ),
2252
+ bytearray (b"3, 3, 0, 0,(N.),(),(|\x00 S\x00 ),(),()" ),
2253
+ bytearray (b"3, 3, 0, 0,(),(),(|\x00 S\x00 ),(),()" ),
2254
+ ),
2255
+ (3 , 11 ): (bytearray (b"3, 3, 0, 0,(),(),(\x97 \x00 |\x00 S\x00 ),(),()" ),),
2256
+ (3 , 12 ): (bytearray (b"3, 3, 0, 0,(),(),(\x97 \x00 |\x00 S\x00 ),(),()" ),),
2257
+ (3 , 13 ): (bytearray (b"3, 3, 0, 0,(),(),(\x95 \x00 U\x00 $\x00 ),(),()" ),),
2258
+ (3 , 14 ): (
2259
+ bytearray (
2260
+ b'3, 3, 0, 0,(),(),(\x80 \x00 T\x00 "\x00 ),(),()'
2261
+ ), # win32 has different bytecodes
2262
+ bytearray (
2263
+ b'3, 3, 0, 0,(),(),(\x80 \x00 R\x00 "\x00 ),(),()'
2264
+ ), # every other OS?
2254
2265
),
2255
- (3 , 11 ): (bytearray (b'3, 3, 0, 0,(),(),(\x97 \x00 |\x00 S\x00 ),(),()' ),),
2256
- (3 , 12 ): (bytearray (b'3, 3, 0, 0,(),(),(\x97 \x00 |\x00 S\x00 ),(),()' ),),
2257
- (3 , 13 ): (bytearray (b'3, 3, 0, 0,(),(),(\x95 \x00 U\x00 $\x00 ),(),()' ),),
2258
- (3 , 14 ): (bytearray (b'3, 3, 0, 0,(),(),(\x80 \x00 R\x00 "\x00 ),(),()' ),),
2259
2266
}
2260
2267
2261
2268
c = SCons .Action ._function_contents (func1 )
@@ -2274,33 +2281,36 @@ def test_object_contents(self) -> None:
2274
2281
# we need different expected results per version
2275
2282
expected = {
2276
2283
(3 , 7 ): bytearray (
2277
- b"{TestClass:__main__}[[[(<class \ ' object\ ' >, ()), [(<class \ ' __main__.TestClass\ ' >, (<class \ ' object\ ' >,))]]]]{{1, 1, 0, 0,(a,b),(a,b),(d\x01 |\x00 _\x00 d\x02 |\x00 _\x01 d\x00 S\x00 ),(),(),2, 2, 0, 0,(),(),(d\x00 S\x00 ),(),()}}{{{a=a,b=b}}}"
2284
+ b"{TestClass:__main__}[[[(<class 'object'>, ()), [(<class '__main__.TestClass'>, (<class 'object'>,))]]]]{{1, 1, 0, 0,(a,b),(a,b),(d\x01 |\x00 _\x00 d\x02 |\x00 _\x01 d\x00 S\x00 ),(),(),2, 2, 0, 0,(),(),(d\x00 S\x00 ),(),()}}{{{a=a,b=b}}}"
2278
2285
),
2279
2286
(3 , 8 ): bytearray (
2280
- b"{TestClass:__main__}[[[(<class \ ' object\ ' >, ()), [(<class \ ' __main__.TestClass\ ' >, (<class \ ' object\ ' >,))]]]]{{1, 1, 0, 0,(a,b),(a,b),(d\x01 |\x00 _\x00 d\x02 |\x00 _\x01 d\x00 S\x00 ),(),(),2, 2, 0, 0,(),(),(d\x00 S\x00 ),(),()}}{{{a=a,b=b}}}"
2287
+ b"{TestClass:__main__}[[[(<class 'object'>, ()), [(<class '__main__.TestClass'>, (<class 'object'>,))]]]]{{1, 1, 0, 0,(a,b),(a,b),(d\x01 |\x00 _\x00 d\x02 |\x00 _\x01 d\x00 S\x00 ),(),(),2, 2, 0, 0,(),(),(d\x00 S\x00 ),(),()}}{{{a=a,b=b}}}"
2281
2288
),
2282
2289
(3 , 9 ): bytearray (
2283
- b"{TestClass:__main__}[[[(<class \ ' object\ ' >, ()), [(<class \ ' __main__.TestClass\ ' >, (<class \ ' object\ ' >,))]]]]{{1, 1, 0, 0,(a,b),(a,b),(d\x01 |\x00 _\x00 d\x02 |\x00 _\x01 d\x00 S\x00 ),(),(),2, 2, 0, 0,(),(),(d\x00 S\x00 ),(),()}}{{{a=a,b=b}}}"
2290
+ b"{TestClass:__main__}[[[(<class 'object'>, ()), [(<class '__main__.TestClass'>, (<class 'object'>,))]]]]{{1, 1, 0, 0,(a,b),(a,b),(d\x01 |\x00 _\x00 d\x02 |\x00 _\x01 d\x00 S\x00 ),(),(),2, 2, 0, 0,(),(),(d\x00 S\x00 ),(),()}}{{{a=a,b=b}}}"
2284
2291
),
2285
2292
(3 , 10 ): bytearray (
2286
- b"{TestClass:__main__}[[[(<class \ ' object\ ' >, ()), [(<class \ ' __main__.TestClass\ ' >, (<class \ ' object\ ' >,))]]]]{{1, 1, 0, 0,(a,b),(a,b),(d\x01 |\x00 _\x00 d\x02 |\x00 _\x01 d\x00 S\x00 ),(),(),2, 2, 0, 0,(),(),(d\x00 S\x00 ),(),()}}{{{a=a,b=b}}}"
2293
+ b"{TestClass:__main__}[[[(<class 'object'>, ()), [(<class '__main__.TestClass'>, (<class 'object'>,))]]]]{{1, 1, 0, 0,(a,b),(a,b),(d\x01 |\x00 _\x00 d\x02 |\x00 _\x01 d\x00 S\x00 ),(),(),2, 2, 0, 0,(),(),(d\x00 S\x00 ),(),()}}{{{a=a,b=b}}}"
2287
2294
),
2288
2295
(3 , 11 ): bytearray (
2289
- b"{TestClass:__main__}[[[(<class \ ' object\ ' >, ()), [(<class \ ' __main__.TestClass\ ' >, (<class \ ' object\ ' >,))]]]]{{1, 1, 0, 0,(a,b),(a,b),(\x97 \x00 d\x01 |\x00 _\x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 d\x02 |\x00 _\x01 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 d\x00 S\x00 ),(),(),2, 2, 0, 0,(),(),(\x97 \x00 d\x00 S\x00 ),(),()}}{{{a=a,b=b}}}"
2296
+ b"{TestClass:__main__}[[[(<class 'object'>, ()), [(<class '__main__.TestClass'>, (<class 'object'>,))]]]]{{1, 1, 0, 0,(a,b),(a,b),(\x97 \x00 d\x01 |\x00 _\x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 d\x02 |\x00 _\x01 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 d\x00 S\x00 ),(),(),2, 2, 0, 0,(),(),(\x97 \x00 d\x00 S\x00 ),(),()}}{{{a=a,b=b}}}"
2290
2297
),
2291
2298
(3 , 12 ): bytearray (
2292
- b"{TestClass:__main__}[[[(<class \ ' object\ ' >, ()), [(<class \ ' __main__.TestClass\ ' >, (<class \ ' object\ ' >,))]]]]{{1, 1, 0, 0,(a,b),(a,b),(\x97 \x00 d\x01 |\x00 _\x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 d\x02 |\x00 _\x01 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 y\x00 ),(),(),2, 2, 0, 0,(),(),(\x97 \x00 y\x00 ),(),()}}{{{a=a,b=b}}}"
2299
+ b"{TestClass:__main__}[[[(<class 'object'>, ()), [(<class '__main__.TestClass'>, (<class 'object'>,))]]]]{{1, 1, 0, 0,(a,b),(a,b),(\x97 \x00 d\x01 |\x00 _\x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 d\x02 |\x00 _\x01 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 y\x00 ),(),(),2, 2, 0, 0,(),(),(\x97 \x00 y\x00 ),(),()}}{{{a=a,b=b}}}"
2293
2300
),
2294
2301
(3 , 13 ): bytearray (
2295
- b"{TestClass:__main__}[[[(<class \ ' object\ ' >, ()), [(<class \ ' __main__.TestClass\ ' >, (<class \ ' object\ ' >,))]]]]{{1, 1, 0, 0,(a,b),(a,b),(\x95 \x00 S\x01 U\x00 l\x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 S\x02 U\x00 l\x01 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 g\x00 ),(),(),2, 2, 0, 0,(),(),(\x95 \x00 g\x00 ),(),()}}{{{a=a,b=b}}}"
2302
+ b"{TestClass:__main__}[[[(<class 'object'>, ()), [(<class '__main__.TestClass'>, (<class 'object'>,))]]]]{{1, 1, 0, 0,(a,b),(a,b),(\x95 \x00 S\x01 U\x00 l\x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 S\x02 U\x00 l\x01 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 g\x00 ),(),(),2, 2, 0, 0,(),(),(\x95 \x00 g\x00 ),(),()}}{{{a=a,b=b}}}"
2296
2303
),
2297
- (3 , 14 ): bytearray (
2298
- b'{TestClass:__main__}[[[(<class \' object\' >, ()), [(<class \' __main__.TestClass\' >, (<class \' object\' >,))]]]]{{1, 1, 0, 0,(a,b),(a,b),(\x80 \x00 P\x00 R\x00 j\x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 P\x01 R\x00 j\x01 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 P\x02 "\x00 ),(),(),2, 2, 0, 0,(),(),(\x80 \x00 P\x00 "\x00 ),(),()}}{{{a=a,b=b}}}'
2304
+ (3 , 14 ): (
2305
+ bytearray (
2306
+ b"{TestClass:__main__}[[[(<class 'object'>, ()), [(<class '__main__.TestClass'>, (<class 'object'>,))]]]]{{1, 1, 0, 0,(a,b),(a,b),(\x80 \x00 P\x00 T\x00 l\x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 P\x01 T\x00 l\x01 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 P\x02 \" \x00 ),(),(),2, 2, 0, 0,(),(),(\x80 \x00 P\x00 \" \x00 ),(),()}}{{{a=a,b=b}}}"
2307
+ ), # win32
2308
+ bytearray (
2309
+ b"{TestClass:__main__}[[[(<class 'object'>, ()), [(<class '__main__.TestClass'>, (<class 'object'>,))]]]]{{1, 1, 0, 0,(a,b),(a,b),(\x80 \x00 P\x00 R\x00 j\x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 P\x01 R\x00 j\x01 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 P\x02 \" \x00 ),(),(),2, 2, 0, 0,(),(),(\x80 \x00 P\x00 \" \x00 ),(),()}}{{{a=a,b=b}}}"
2310
+ ),
2299
2311
),
2300
2312
}
2301
-
2302
- # self.assertEqual(c, expected[sys.version_info[:2]])
2303
- assert c == expected [sys .version_info [:2 ]], c
2313
+ self .assertTrue (c in expected [sys .version_info [:2 ]])
2304
2314
2305
2315
def test_code_contents (self ) -> None :
2306
2316
"""Test that Action._code_contents works"""
@@ -2311,32 +2321,37 @@ def test_code_contents(self) -> None:
2311
2321
# Since the python bytecode has per version differences, we need different expected results per version
2312
2322
expected = {
2313
2323
(3 , 7 ): bytearray (
2314
- b' 0, 0, 0, 0,(Hello, World!),(print),(e\x00 d\x00 \x83 \x01 \x01 \x00 d\x01 S\x00 )'
2324
+ b" 0, 0, 0, 0,(Hello, World!),(print),(e\x00 d\x00 \x83 \x01 \x01 \x00 d\x01 S\x00 )"
2315
2325
),
2316
2326
(3 , 8 ): bytearray (
2317
- b' 0, 0, 0, 0,(Hello, World!),(print),(e\x00 d\x00 \x83 \x01 \x01 \x00 d\x01 S\x00 )'
2327
+ b" 0, 0, 0, 0,(Hello, World!),(print),(e\x00 d\x00 \x83 \x01 \x01 \x00 d\x01 S\x00 )"
2318
2328
),
2319
2329
(3 , 9 ): bytearray (
2320
- b' 0, 0, 0, 0,(Hello, World!),(print),(e\x00 d\x00 \x83 \x01 \x01 \x00 d\x01 S\x00 )'
2330
+ b" 0, 0, 0, 0,(Hello, World!),(print),(e\x00 d\x00 \x83 \x01 \x01 \x00 d\x01 S\x00 )"
2321
2331
),
2322
2332
(3 , 10 ): bytearray (
2323
- b' 0, 0, 0, 0,(Hello, World!),(print),(e\x00 d\x00 \x83 \x01 \x01 \x00 d\x01 S\x00 )'
2333
+ b" 0, 0, 0, 0,(Hello, World!),(print),(e\x00 d\x00 \x83 \x01 \x01 \x00 d\x01 S\x00 )"
2324
2334
),
2325
2335
(3 , 11 ): bytearray (
2326
- b' 0, 0, 0, 0,(Hello, World!),(print),(\x97 \x00 \x02 \x00 e\x00 d\x00 \xa6 \x01 \x00 \x00 \xab \x01 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x01 \x00 d\x01 S\x00 )'
2336
+ b" 0, 0, 0, 0,(Hello, World!),(print),(\x97 \x00 \x02 \x00 e\x00 d\x00 \xa6 \x01 \x00 \x00 \xab \x01 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x01 \x00 d\x01 S\x00 )"
2327
2337
),
2328
2338
(3 , 12 ): bytearray (
2329
- b' 0, 0, 0, 0,(Hello, World!),(print),(\x97 \x00 \x02 \x00 e\x00 d\x00 \xab \x01 \x00 \x00 \x00 \x00 \x00 \x00 \x01 \x00 y\x01 )'
2339
+ b" 0, 0, 0, 0,(Hello, World!),(print),(\x97 \x00 \x02 \x00 e\x00 d\x00 \xab \x01 \x00 \x00 \x00 \x00 \x00 \x00 \x01 \x00 y\x01 )"
2330
2340
),
2331
2341
(3 , 13 ): bytearray (
2332
2342
b'0, 0, 0, 0,(Hello, World!),(print),(\x95 \x00 \\ \x00 "\x00 S\x00 5\x01 \x00 \x00 \x00 \x00 \x00 \x00 \x00 g\x01 )'
2333
2343
),
2334
- (3 , 14 ): bytearray (
2335
- b'0, 0, 0, 0,(Hello, World!),(print),(\x80 \x00 Y\x00 \x00 P\x00 2\x01 \x00 \x00 \x00 \x00 \x00 \x00 \x1e \x00 P\x01 "\x00 )'
2344
+ (3 , 14 ): (
2345
+ bytearray (
2346
+ b'0, 0, 0, 0,(Hello, World!),(print),(\x80 \x00 [\x00 \x00 P\x00 2\x01 \x00 \x00 \x00 \x00 \x00 \x00 \x1e \x00 P\x01 "\x00 )'
2347
+ ), # win32
2348
+ bytearray (
2349
+ b'0, 0, 0, 0,(Hello, World!),(print),(\x80 \x00 Y\x00 \x00 P\x00 2\x01 \x00 \x00 \x00 \x00 \x00 \x00 \x1e \x00 P\x01 "\x00 )'
2350
+ ),
2336
2351
),
2337
2352
}
2338
2353
2339
- self .assertEqual ( c , expected [sys .version_info [:2 ]])
2354
+ self .assertTrue ( c in expected [sys .version_info [:2 ]], f" \n Expected: { expected [ sys . version_info [: 2 ]] } \n Got : { c } " )
2340
2355
2341
2356
def test_uncaught_exception_bubbles (self ):
2342
2357
"""Test that scons_subproc_run bubbles uncaught exceptions"""
@@ -2350,7 +2365,6 @@ def test_uncaught_exception_bubbles(self):
2350
2365
2351
2366
raise Exception ("expected a non-EnvironmentError exception" )
2352
2367
2353
-
2354
2368
def mock_subprocess_run (* args , ** kwargs ):
2355
2369
"""Replacement subprocess.run: return kwargs for checking."""
2356
2370
kwargs .pop ("env" ) # the value of env isn't interesting here
0 commit comments