@@ -349,6 +349,14 @@ def test_tag_eq():
349
349
350
350
assert (tag == tag2 )
351
351
352
+ def test_tag_eq_not_same_object_type ():
353
+ tag = pycdlib .udf .UDFTag ()
354
+ tag .new (0 , 0 )
355
+
356
+ not_a_tag = object ()
357
+
358
+ assert (tag != not_a_tag )
359
+
352
360
# Anchor
353
361
def test_anchor_parse_initialized_twice ():
354
362
anchor = pycdlib .udf .UDFAnchorVolumeStructure ()
@@ -384,6 +392,14 @@ def test_anchor_set_extent_location_not_initialized():
384
392
anchor .set_extent_location (0 , 0 , 0 )
385
393
assert (str (excinfo .value ) == 'UDF Anchor Volume Structure not initialized' )
386
394
395
+ def test_anchor_eq_not_same_object_type ():
396
+ anchor = pycdlib .udf .UDFAnchorVolumeStructure ()
397
+ anchor .new ()
398
+
399
+ not_an_anchor = object ()
400
+
401
+ assert (anchor != not_an_anchor )
402
+
387
403
# Volume Descriptor Pointer
388
404
def test_vdp_parse_initialized_twice ():
389
405
vdp = pycdlib .udf .UDFVolumeDescriptorPointer ()
@@ -530,6 +546,14 @@ def test_timestamp_equal():
530
546
531
547
assert (ts == ts2 )
532
548
549
+ def test_timestamp_eq_not_same_object_type ():
550
+ ts = pycdlib .udf .UDFTimestamp ()
551
+ ts .new (time .time ())
552
+
553
+ not_a_ts = object ()
554
+
555
+ assert (ts != not_a_ts )
556
+
533
557
# EntityID
534
558
def test_entityid_parse_initialized_twice ():
535
559
entity = pycdlib .udf .UDFEntityID ()
@@ -584,6 +608,14 @@ def test_entityid_equals():
584
608
585
609
assert (entity == entity2 )
586
610
611
+ def test_entityid_eq_not_same_object_type ():
612
+ entity = pycdlib .udf .UDFEntityID ()
613
+ entity .new (0 )
614
+
615
+ not_an_entity = object ()
616
+
617
+ assert (entity != not_an_entity )
618
+
587
619
# Charspec
588
620
def test_charspec_parse_initialized_twice ():
589
621
charspec = pycdlib .udf .UDFCharspec ()
@@ -632,6 +664,14 @@ def test_charspec_equal():
632
664
633
665
assert (charspec == charspec2 )
634
666
667
+ def test_charspec_eq_not_same_object_type ():
668
+ charspec = pycdlib .udf .UDFCharspec ()
669
+ charspec .new (0 , b'\x00 ' * 63 )
670
+
671
+ not_a_charspec = object ()
672
+
673
+ assert (charspec != not_a_charspec )
674
+
635
675
# ExtentAD
636
676
def test_extentad_parse_initialized_twice ():
637
677
extentad = pycdlib .udf .UDFExtentAD ()
@@ -674,6 +714,14 @@ def test_extentad_equals():
674
714
675
715
assert (extentad == extentad2 )
676
716
717
+ def test_extentad_eq_not_same_object_type ():
718
+ extentad = pycdlib .udf .UDFExtentAD ()
719
+ extentad .new (0 , 0 )
720
+
721
+ not_an_extentad = object ()
722
+
723
+ assert (extentad != not_an_extentad )
724
+
677
725
# PVD
678
726
def test_pvd_parse_initialized_twice ():
679
727
pvd = pycdlib .udf .UDFPrimaryVolumeDescriptor ()
@@ -776,6 +824,14 @@ def test_pvd_equals():
776
824
777
825
assert (pvd == pvd2 )
778
826
827
+ def test_pvd_eq_not_same_object_type ():
828
+ pvd = pycdlib .udf .UDFPrimaryVolumeDescriptor ()
829
+ pvd .new ()
830
+
831
+ not_a_pvd = object ()
832
+
833
+ assert (pvd != not_a_pvd )
834
+
779
835
# Implementation Use Volume Descriptor Implementation Use
780
836
def test_impl_use_impl_use_parse_initialized_twice ():
781
837
impl = pycdlib .udf .UDFImplementationUseVolumeDescriptorImplementationUse ()
@@ -797,7 +853,7 @@ def test_impl_use_impl_use_new_initialized_twice():
797
853
impl .new ()
798
854
assert (str (excinfo .value ) == 'UDF Implementation Use Volume Descriptor Implementation Use field already initialized' )
799
855
800
- def test_impl_use_impl_use_new_equals ():
856
+ def test_impl_use_impl_use_equals ():
801
857
impl = pycdlib .udf .UDFImplementationUseVolumeDescriptorImplementationUse ()
802
858
impl .new ()
803
859
@@ -806,6 +862,14 @@ def test_impl_use_impl_use_new_equals():
806
862
807
863
assert (impl == impl2 )
808
864
865
+ def test_impl_use_impl_use_eq_not_same_object_type ():
866
+ impl = pycdlib .udf .UDFImplementationUseVolumeDescriptorImplementationUse ()
867
+ impl .new ()
868
+
869
+ not_an_impl = object ()
870
+
871
+ assert (impl != not_an_impl )
872
+
809
873
# Implementation Use
810
874
def test_impl_use_parse_initialized_twice ():
811
875
impl = pycdlib .udf .UDFImplementationUseVolumeDescriptor ()
@@ -858,6 +922,14 @@ def test_impl_use_equals():
858
922
859
923
assert (impl == impl2 )
860
924
925
+ def test_impl_use_eq_not_same_object_type ():
926
+ impl = pycdlib .udf .UDFImplementationUseVolumeDescriptor ()
927
+ impl .new ()
928
+
929
+ not_an_impl = object ()
930
+
931
+ assert (impl != not_an_impl )
932
+
861
933
# Partition Header Descriptor
862
934
def test_part_header_parse_initialized_twice ():
863
935
header = pycdlib .udf .UDFPartitionHeaderDescriptor ()
@@ -888,6 +960,14 @@ def test_part_header_equals():
888
960
889
961
assert (header == header2 )
890
962
963
+ def test_part_header_eq_not_same_object_type ():
964
+ header = pycdlib .udf .UDFPartitionHeaderDescriptor ()
965
+ header .new ()
966
+
967
+ not_a_header = object ()
968
+
969
+ assert (header != not_a_header )
970
+
891
971
# Partition Volume
892
972
def test_part_parse_initialized_twice ():
893
973
part = pycdlib .udf .UDFPartitionVolumeDescriptor ()
@@ -973,6 +1053,14 @@ def test_part_equals():
973
1053
974
1054
assert (part == part2 )
975
1055
1056
+ def test_part_eq_not_same_object_type ():
1057
+ part = pycdlib .udf .UDFPartitionVolumeDescriptor ()
1058
+ part .new (3 )
1059
+
1060
+ not_a_part = object ()
1061
+
1062
+ assert (part != not_a_part )
1063
+
976
1064
# Type 0 Partition Map
977
1065
def test_type_zero_part_map_parse_initialized_twice ():
978
1066
partmap = pycdlib .udf .UDFType0PartitionMap ()
@@ -1180,6 +1268,14 @@ def test_shortad_set_extent_location():
1180
1268
ad .set_extent_location (0 , 1 )
1181
1269
assert (ad .log_block_num == 1 )
1182
1270
1271
+ def test_shortad_eq_not_same_object_type ():
1272
+ ad = pycdlib .udf .UDFShortAD ()
1273
+ ad .new (0 )
1274
+
1275
+ not_an_ad = object ()
1276
+
1277
+ assert (ad != not_an_ad )
1278
+
1183
1279
# Long AD
1184
1280
def test_longad_parse_initialized_twice ():
1185
1281
ad = pycdlib .udf .UDFLongAD ()
@@ -1220,6 +1316,14 @@ def test_longad_equals():
1220
1316
1221
1317
assert (ad == ad2 )
1222
1318
1319
+ def test_longad_eq_not_same_object_type ():
1320
+ ad = pycdlib .udf .UDFLongAD ()
1321
+ ad .new (0 , 0 )
1322
+
1323
+ not_an_ad = object ()
1324
+
1325
+ assert (ad != not_an_ad )
1326
+
1223
1327
# Inline AD
1224
1328
def test_inlinead_parse_initialized_twice ():
1225
1329
ad = pycdlib .udf .UDFInlineAD ()
@@ -1417,6 +1521,14 @@ def test_logvoldesc_equals():
1417
1521
1418
1522
assert (logvol == logvol2 )
1419
1523
1524
+ def test_logvoldesc_eq_not_same_object_type ():
1525
+ logvol = pycdlib .udf .UDFLogicalVolumeDescriptor ()
1526
+ logvol .new ()
1527
+
1528
+ not_a_logvol = object ()
1529
+
1530
+ assert (logvol != not_a_logvol )
1531
+
1420
1532
# Unallocated Space
1421
1533
def test_unallocated_parse_initialized_twice ():
1422
1534
un = pycdlib .udf .UDFUnallocatedSpaceDescriptor ()
@@ -1483,6 +1595,14 @@ def test_unallocated_equals():
1483
1595
1484
1596
assert (un == un2 )
1485
1597
1598
+ def test_unallocated_eq_not_same_object_type ():
1599
+ un = pycdlib .udf .UDFUnallocatedSpaceDescriptor ()
1600
+ un .new ()
1601
+
1602
+ not_a_un = object ()
1603
+
1604
+ assert (un != not_a_un )
1605
+
1486
1606
# Terminating Descriptor
1487
1607
def test_terminating_parse_initialized_twice ():
1488
1608
term = pycdlib .udf .UDFTerminatingDescriptor ()
@@ -1742,6 +1862,18 @@ def test_icbtag_new_bad_file_type():
1742
1862
icb .new ('foo' )
1743
1863
assert (str (excinfo .value ) == "Invalid file type for ICB; must be one of 'dir', 'file', or 'symlink'" )
1744
1864
1865
+ def test_icbtag_parse_bad_strategy_type ():
1866
+ icb = pycdlib .udf .UDFICBTag ()
1867
+ with pytest .raises (pycdlib .pycdlibexception .PyCdlibInvalidISO ) as excinfo :
1868
+ icb .parse (b'\x00 \x00 \x00 \x00 \x03 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 ' )
1869
+ assert (str (excinfo .value ) == 'UDF ICB Tag invalid strategy type' )
1870
+
1871
+ def test_icbtag_parse_bad_reserved ():
1872
+ icb = pycdlib .udf .UDFICBTag ()
1873
+ with pytest .raises (pycdlib .pycdlibexception .PyCdlibInvalidISO ) as excinfo :
1874
+ icb .parse (b'\x00 \x00 \x00 \x00 \x04 \x00 \x00 \x00 \x00 \x00 \x01 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 ' )
1875
+ assert (str (excinfo .value ) == 'UDF ICB Tag reserved not 0' )
1876
+
1745
1877
# File Entry
1746
1878
def test_file_entry_parse_initialized_twice ():
1747
1879
entry = pycdlib .udf .UDFFileEntry ()
@@ -2088,7 +2220,25 @@ def test_file_ident_equals_other_parent():
2088
2220
fi2 = pycdlib .udf .UDFFileIdentifierDescriptor ()
2089
2221
fi2 .new (False , False , b'bar' , None )
2090
2222
2091
- assert (not fi == fi2 )
2223
+ assert (fi != fi2 )
2224
+
2225
+ def test_file_ident_eq_not_same_object_type ():
2226
+ fi = pycdlib .udf .UDFFileIdentifierDescriptor ()
2227
+ fi .new (False , True , b'foo' , None )
2228
+
2229
+ not_an_fi = object ()
2230
+
2231
+ assert (fi != not_an_fi )
2232
+
2233
+ def test_file_ident_eq_not_other_parent ():
2234
+ fi = pycdlib .udf .UDFFileIdentifierDescriptor ()
2235
+ # isdir, isparent, name, parent
2236
+ fi .new (False , False , b'foo' , None )
2237
+
2238
+ fi2 = pycdlib .udf .UDFFileIdentifierDescriptor ()
2239
+ fi2 .new (False , True , b'bar' , None )
2240
+
2241
+ assert (fi != fi2 )
2092
2242
2093
2243
# Space Bitmap
2094
2244
def test_space_bitmap_parse_initialized_twice ():
@@ -2296,7 +2446,7 @@ def test_indirect_new():
2296
2446
assert (indirect .desc_tag .tag_ident == 259 )
2297
2447
2298
2448
# Terminating
2299
- def test_terminating_parse_initialized_twice ():
2449
+ def test_terminal_entry_parse_initialized_twice ():
2300
2450
tag = pycdlib .udf .UDFTag ()
2301
2451
tag .new (0 , 0 )
2302
2452
@@ -2306,36 +2456,36 @@ def test_terminating_parse_initialized_twice():
2306
2456
term .parse (b'\x00 ' * 16 + b'\x00 ' * 20 , tag )
2307
2457
assert (str (excinfo .value ) == 'UDF Terminal Entry already initialized' )
2308
2458
2309
- def test_terminating_parse ():
2459
+ def test_terminal_entry_parse ():
2310
2460
tag = pycdlib .udf .UDFTag ()
2311
2461
tag .new (0 , 0 )
2312
2462
2313
2463
term = pycdlib .udf .UDFTerminalEntry ()
2314
2464
term .parse (b'\x00 ' * 16 + b'\x00 \x00 \x00 \x00 \x04 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 ' , tag )
2315
2465
assert (term .desc_tag .tag_ident == 0 )
2316
2466
2317
- def test_terminating_record_not_initialized ():
2467
+ def test_terminal_entry_record_not_initialized ():
2318
2468
term = pycdlib .udf .UDFTerminalEntry ()
2319
2469
with pytest .raises (pycdlib .pycdlibexception .PyCdlibInternalError ) as excinfo :
2320
2470
term .record ()
2321
2471
assert (str (excinfo .value ) == 'UDF Terminal Entry not initialized' )
2322
2472
2323
- def test_terminating_record ():
2473
+ def test_terminal_entry_record ():
2324
2474
tag = pycdlib .udf .UDFTag ()
2325
2475
tag .new (0 , 0 )
2326
2476
2327
2477
term = pycdlib .udf .UDFTerminalEntry ()
2328
2478
term .parse (b'\x00 ' * 16 + b'\x00 \x00 \x00 \x00 \x04 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 ' , tag )
2329
2479
assert (term .record () == b'\x00 \x00 \x02 \x00 \x68 \x00 \x00 \x00 \xd2 \x80 \x14 \x00 \x00 \x00 \x00 \x00 ' + b'\x00 \x00 \x00 \x00 \x04 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 ' )
2330
2480
2331
- def test_terminating_new_initialized_twice ():
2481
+ def test_terminal_entry_new_initialized_twice ():
2332
2482
term = pycdlib .udf .UDFTerminalEntry ()
2333
2483
term .new ('dir' )
2334
2484
with pytest .raises (pycdlib .pycdlibexception .PyCdlibInternalError ) as excinfo :
2335
2485
term .new ('dir' )
2336
2486
assert (str (excinfo .value ) == 'UDF Terminal Entry already initialized' )
2337
2487
2338
- def test_terminating_new ():
2488
+ def test_terminal_entry_new ():
2339
2489
term = pycdlib .udf .UDFTerminalEntry ()
2340
2490
term .new ('dir' )
2341
2491
assert (term .desc_tag .tag_ident == 260 )
0 commit comments