@@ -34,9 +34,11 @@ def test_directory_optional_contents(tmp_path):
34
34
35
35
optional_dir = DirectoryOf [MyFormatGz , ty .Optional [YourFormat ]](sample_dir )
36
36
assert optional_dir .contents == [my_format ]
37
+
37
38
your_format = YourFormat .sample (dest_dir = tmp_path )
38
39
optional_dir = DirectoryOf [MyFormatGz , ty .Optional [YourFormat ]](sample_dir )
39
40
assert optional_dir .contents == [my_format , your_format ]
41
+
40
42
required_dir = DirectoryOf [MyFormatGz , YourFormat ](sample_dir )
41
43
assert required_dir .contents == [my_format , your_format ]
42
44
@@ -47,15 +49,24 @@ def test_set_optional_contents():
47
49
48
50
sample_set = SetOf [MyFormatGz , YourFormat ](my_format , your_format )
49
51
assert sample_set .contents == [my_format , your_format ]
50
- with pytest .raises (
51
- FormatMismatchError , match = "are not used by any of the contents of "
52
- ):
53
- SetOf [MyFormatGz ](my_format , your_format )
52
+ assert set (sample_set .required_paths ()) == {my_format .fspath , your_format .fspath }
53
+
54
+ sample_set = SetOf [MyFormatGz ](my_format , your_format )
55
+ assert list (sample_set .required_paths ()) == [my_format .fspath ]
56
+
54
57
with pytest .raises (
55
58
FormatMismatchError , match = "Did not find the required content types"
56
59
):
57
60
SetOf [MyFormatGz , YourFormat ](my_format )
61
+
58
62
sample_set = SetOf [MyFormatGz , ty .Optional [YourFormat ]](my_format )
59
63
assert sample_set .contents == [my_format ]
64
+ assert list (sample_set .required_paths ()) == [my_format .fspath ]
65
+
60
66
sample_set = SetOf [MyFormatGz , ty .Optional [YourFormat ]](my_format , your_format )
61
67
assert sample_set .contents == [my_format , your_format ]
68
+ assert set (sample_set .required_paths ()) == {my_format .fspath , your_format .fspath }
69
+
70
+ sample_set = SetOf [ty .Optional [MyFormatGz ]](my_format )
71
+ assert sample_set .contents == [my_format ]
72
+ assert list (sample_set .required_paths ()) == [my_format .fspath ]
0 commit comments