tests/config/yaml: use pytest_collect_file() hook for YAML files
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 10 Sep 2020 04:06:41 +0000 (00:06 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 10 Sep 2020 04:06:41 +0000 (00:06 -0400)
This patch changes `tests/config/yaml/conftest.py` so that it implements
a pytest_collect_file() Pytest hook to create Pytest file and item
objects for each failing barectf YAML configuration file found.

This makes is possible to remove all `test_fail_*.py` files and avoid
duplication and mismatches between existing YAML files and available
test functions.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
15 files changed:
tests/config/yaml/2/test_fail_clock.py [deleted file]
tests/config/yaml/2/test_fail_config.py [deleted file]
tests/config/yaml/2/test_fail_event.py [deleted file]
tests/config/yaml/2/test_fail_include.py [deleted file]
tests/config/yaml/2/test_fail_metadata.py [deleted file]
tests/config/yaml/2/test_fail_stream.py [deleted file]
tests/config/yaml/2/test_fail_trace.py [deleted file]
tests/config/yaml/2/test_fail_type.py [deleted file]
tests/config/yaml/2/test_fail_type_enum.py [deleted file]
tests/config/yaml/2/test_fail_type_float.py [deleted file]
tests/config/yaml/2/test_fail_type_int.py [deleted file]
tests/config/yaml/2/test_fail_type_string.py [deleted file]
tests/config/yaml/2/test_fail_type_struct.py [deleted file]
tests/config/yaml/2/test_fail_yaml.py [deleted file]
tests/config/yaml/conftest.py

diff --git a/tests/config/yaml/2/test_fail_clock.py b/tests/config/yaml/2/test_fail_clock.py
deleted file mode 100644 (file)
index a83d2a2..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-# The MIT License (MIT)
-#
-# Copyright (c) 2020 Philippe Proulx <pproulx@efficios.com>
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-def test_absolute_invalid_type(config_fail_test):
-    config_fail_test()
-
-
-def test_description_invalid_type(config_fail_test):
-    config_fail_test()
-
-
-def test_ec_invalid_type(config_fail_test):
-    config_fail_test()
-
-
-def test_ec_invalid(config_fail_test):
-    config_fail_test()
-
-
-def test_freq_0(config_fail_test):
-    config_fail_test()
-
-
-def test_freq_invalid_type(config_fail_test):
-    config_fail_test()
-
-
-def test_freq_neg(config_fail_test):
-    config_fail_test()
-
-
-def test_offset_cycles_invalid_type(config_fail_test):
-    config_fail_test()
-
-
-def test_offset_cycles_neg(config_fail_test):
-    config_fail_test()
-
-
-def test_offset_invalid_type(config_fail_test):
-    config_fail_test()
-
-
-def test_offset_seconds_invalid_type(config_fail_test):
-    config_fail_test()
-
-
-def test_offset_seconds_neg(config_fail_test):
-    config_fail_test()
-
-
-def test_offset_unknown_prop(config_fail_test):
-    config_fail_test()
-
-
-def test_rct_invalid_type(config_fail_test):
-    config_fail_test()
-
-
-def test_unknown_prop(config_fail_test):
-    config_fail_test()
-
-
-def test_uuid_invalid_type(config_fail_test):
-    config_fail_test()
-
-
-def test_uuid_invalid(config_fail_test):
-    config_fail_test()
diff --git a/tests/config/yaml/2/test_fail_config.py b/tests/config/yaml/2/test_fail_config.py
deleted file mode 100644 (file)
index 99f27c7..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-# The MIT License (MIT)
-#
-# Copyright (c) 2020 Philippe Proulx <pproulx@efficios.com>
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-def test_metadata_invalid_type(config_fail_test):
-    config_fail_test()
-
-
-def test_metadata_no(config_fail_test):
-    config_fail_test()
-
-
-def test_options_gen_default_stream_def_invalid_type(config_fail_test):
-    config_fail_test()
-
-
-def test_options_gen_prefix_def_invalid_type(config_fail_test):
-    config_fail_test()
-
-
-def test_options_invalid_type(config_fail_test):
-    config_fail_test()
-
-
-def test_options_unknown_prop(config_fail_test):
-    config_fail_test()
-
-
-def test_prefix_invalid_identifier(config_fail_test):
-    config_fail_test()
-
-
-def test_prefix_invalid_type(config_fail_test):
-    config_fail_test()
-
-
-def test_unknown_prop(config_fail_test):
-    config_fail_test()
-
-
-def test_version_invalid_19(config_fail_test):
-    config_fail_test()
-
-
-def test_version_invalid_23(config_fail_test):
-    config_fail_test()
-
-
-def test_version_invalid_type(config_fail_test):
-    config_fail_test()
-
-
-def test_version_no(config_fail_test):
-    config_fail_test()
diff --git a/tests/config/yaml/2/test_fail_event.py b/tests/config/yaml/2/test_fail_event.py
deleted file mode 100644 (file)
index 6d4c0a2..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-# The MIT License (MIT)
-#
-# Copyright (c) 2020 Philippe Proulx <pproulx@efficios.com>
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-def test_ct_invalid_type(config_fail_test):
-    config_fail_test()
-
-
-def test_ct_not_struct(config_fail_test):
-    config_fail_test()
-
-
-def test_ll_invalid_type(config_fail_test):
-    config_fail_test()
-
-
-def test_ll_non_existing(config_fail_test):
-    config_fail_test()
-
-
-def test_no_fields_at_all(config_fail_test):
-    config_fail_test()
-
-
-def test_pt_invalid_type(config_fail_test):
-    config_fail_test()
-
-
-def test_pt_not_struct(config_fail_test):
-    config_fail_test()
-
-
-def test_unknown_prop(config_fail_test):
-    config_fail_test()
diff --git a/tests/config/yaml/2/test_fail_include.py b/tests/config/yaml/2/test_fail_include.py
deleted file mode 100644 (file)
index 1e70ec7..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-# The MIT License (MIT)
-#
-# Copyright (c) 2020 Philippe Proulx <pproulx@efficios.com>
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-def test_invalid_type(config_fail_test):
-    config_fail_test()
-
-
-def test_file_not_found(config_fail_test):
-    config_fail_test()
-
-
-def test_file_not_found_abs(config_fail_test):
-    config_fail_test()
-
-
-def test_file_not_found_in_array(config_fail_test):
-    config_fail_test()
-
-
-def test_file_not_found_recursive(config_fail_test):
-    config_fail_test()
-
-
-def test_cycle(config_fail_test):
-    config_fail_test()
diff --git a/tests/config/yaml/2/test_fail_metadata.py b/tests/config/yaml/2/test_fail_metadata.py
deleted file mode 100644 (file)
index c131cb9..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-# The MIT License (MIT)
-#
-# Copyright (c) 2020 Philippe Proulx <pproulx@efficios.com>
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-def test_clocks_invalid_type(config_fail_test):
-    config_fail_test()
-
-
-def test_clocks_key_invalid_identifier(config_fail_test):
-    config_fail_test()
-
-
-def test_default_stream_invalid_type(config_fail_test):
-    config_fail_test()
-
-
-def test_default_stream_stream_default_duplicate(config_fail_test):
-    config_fail_test()
-
-
-def test_default_stream_unknown_stream(config_fail_test):
-    config_fail_test()
-
-
-def test_env_invalid_type(config_fail_test):
-    config_fail_test()
-
-
-def test_env_key_invalid_identifier(config_fail_test):
-    config_fail_test()
-
-
-def test_env_value_invalid_type(config_fail_test):
-    config_fail_test()
-
-
-def test_ll_invalid_type(config_fail_test):
-    config_fail_test()
-
-
-def test_ll_value_invalid_type(config_fail_test):
-    config_fail_test()
-
-
-def test_multiple_streams_trace_ph_no_stream_id(config_fail_test):
-    config_fail_test()
-
-
-def test_streams_empty(config_fail_test):
-    config_fail_test()
-
-
-def test_streams_invalid_type(config_fail_test):
-    config_fail_test()
-
-
-def test_streams_key_invalid_identifier(config_fail_test):
-    config_fail_test()
-
-
-def test_streams_no(config_fail_test):
-    config_fail_test()
-
-
-def test_ta_invalid_type(config_fail_test):
-    config_fail_test()
-
-
-def test_trace_empty(config_fail_test):
-    config_fail_test()
-
-
-def test_trace_invalid_type(config_fail_test):
-    config_fail_test()
-
-
-def test_trace_no(config_fail_test):
-    config_fail_test()
-
-
-def test_unknown_prop(config_fail_test):
-    config_fail_test()
diff --git a/tests/config/yaml/2/test_fail_stream.py b/tests/config/yaml/2/test_fail_stream.py
deleted file mode 100644 (file)
index 3b640da..0000000
+++ /dev/null
@@ -1,169 +0,0 @@
-# The MIT License (MIT)
-#
-# Copyright (c) 2020 Philippe Proulx <pproulx@efficios.com>
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-def test_default_invalid_type(config_fail_test):
-    config_fail_test()
-
-
-def test_ect_invalid_type(config_fail_test):
-    config_fail_test()
-
-
-def test_ect_not_struct(config_fail_test):
-    config_fail_test()
-
-
-def test_eht_id_no_multiple_events(config_fail_test):
-    config_fail_test()
-
-
-def test_eht_id_not_int(config_fail_test):
-    config_fail_test()
-
-
-def test_eht_id_too_small(config_fail_test):
-    config_fail_test()
-
-
-def test_eht_id_wrong_signed(config_fail_test):
-    config_fail_test()
-
-
-def test_eht_invalid_type(config_fail_test):
-    config_fail_test()
-
-
-def test_eht_not_struct(config_fail_test):
-    config_fail_test()
-
-
-def test_eht_timestamp_not_int(config_fail_test):
-    config_fail_test()
-
-
-def test_eht_timestamp_wrong_pm(config_fail_test):
-    config_fail_test()
-
-
-def test_eht_timestamp_wrong_signed(config_fail_test):
-    config_fail_test()
-
-
-def test_events_empty(config_fail_test):
-    config_fail_test()
-
-
-def test_events_invalid_type(config_fail_test):
-    config_fail_test()
-
-
-def test_events_key_invalid_identifier(config_fail_test):
-    config_fail_test()
-
-
-def test_events_no(config_fail_test):
-    config_fail_test()
-
-
-def test_pct_cs_not_int(config_fail_test):
-    config_fail_test()
-
-
-def test_pct_cs_wrong_signed(config_fail_test):
-    config_fail_test()
-
-
-def test_pct_cs_yes_ps_no(config_fail_test):
-    config_fail_test()
-
-
-def test_pct_ed_not_int(config_fail_test):
-    config_fail_test()
-
-
-def test_pct_ed_wrong_signed(config_fail_test):
-    config_fail_test()
-
-
-def test_pct_invalid_type(config_fail_test):
-    config_fail_test()
-
-
-def test_pct_not_struct(config_fail_test):
-    config_fail_test()
-
-
-def test_pct_no(config_fail_test):
-    config_fail_test()
-
-
-def test_pct_ps_not_int(config_fail_test):
-    config_fail_test()
-
-
-def test_pct_ps_wrong_signed(config_fail_test):
-    config_fail_test()
-
-
-def test_pct_ps_yes_cs_no(config_fail_test):
-    config_fail_test()
-
-
-def test_pct_tb_not_int(config_fail_test):
-    config_fail_test()
-
-
-def test_pct_tb_te_different_clocks(config_fail_test):
-    config_fail_test()
-
-
-def test_pct_tb_wrong_pm(config_fail_test):
-    config_fail_test()
-
-
-def test_pct_tb_wrong_signed(config_fail_test):
-    config_fail_test()
-
-
-def test_pct_tb_yes_te_no(config_fail_test):
-    config_fail_test()
-
-
-def test_pct_te_not_int(config_fail_test):
-    config_fail_test()
-
-
-def test_pct_te_wrong_pm(config_fail_test):
-    config_fail_test()
-
-
-def test_pct_te_wrong_signed(config_fail_test):
-    config_fail_test()
-
-
-def test_pct_te_yes_tb_no(config_fail_test):
-    config_fail_test()
-
-
-def test_unknown_prop(config_fail_test):
-    config_fail_test()
diff --git a/tests/config/yaml/2/test_fail_trace.py b/tests/config/yaml/2/test_fail_trace.py
deleted file mode 100644 (file)
index 951c4f8..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-# The MIT License (MIT)
-#
-# Copyright (c) 2020 Philippe Proulx <pproulx@efficios.com>
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-def test_bo_invalid_type(config_fail_test):
-    config_fail_test()
-
-
-def test_bo_invalid(config_fail_test):
-    config_fail_test()
-
-
-def test_bo_no(config_fail_test):
-    config_fail_test()
-
-
-def test_ph_magic_not_int(config_fail_test):
-    config_fail_test()
-
-
-def test_ph_magic_wrong_signed(config_fail_test):
-    config_fail_test()
-
-
-def test_ph_magic_wrong_size(config_fail_test):
-    config_fail_test()
-
-
-def test_ph_not_struct(config_fail_test):
-    config_fail_test()
-
-
-def test_ph_streamid_not_int(config_fail_test):
-    config_fail_test()
-
-
-def test_ph_streamid_too_small(config_fail_test):
-    config_fail_test()
-
-
-def test_ph_streamid_wrong_signed(config_fail_test):
-    config_fail_test()
-
-
-def test_ph_uuid_et_not_int(config_fail_test):
-    config_fail_test()
-
-
-def test_ph_uuid_et_wrong_align(config_fail_test):
-    config_fail_test()
-
-
-def test_ph_uuid_et_wrong_signed(config_fail_test):
-    config_fail_test()
-
-
-def test_ph_uuid_et_wrong_size(config_fail_test):
-    config_fail_test()
-
-
-def test_ph_uuid_not_array(config_fail_test):
-    config_fail_test()
-
-
-def test_ph_uuid_wrong_length(config_fail_test):
-    config_fail_test()
-
-
-def test_unknown_prop(config_fail_test):
-    config_fail_test()
-
-
-def test_uuid_invalid_type(config_fail_test):
-    config_fail_test()
-
-
-def test_uuid_invalid_uuid(config_fail_test):
-    config_fail_test()
diff --git a/tests/config/yaml/2/test_fail_type.py b/tests/config/yaml/2/test_fail_type.py
deleted file mode 100644 (file)
index 4b9cc32..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-# The MIT License (MIT)
-#
-# Copyright (c) 2020 Philippe Proulx <pproulx@efficios.com>
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-def test_inherit_forward(config_fail_test):
-    config_fail_test()
-
-
-def test_inherit_unknown(config_fail_test):
-    config_fail_test()
-
-
-def test_invalid_type(config_fail_test):
-    config_fail_test()
-
-
-def test_no_class(config_fail_test):
-    config_fail_test()
diff --git a/tests/config/yaml/2/test_fail_type_enum.py b/tests/config/yaml/2/test_fail_type_enum.py
deleted file mode 100644 (file)
index 6911de6..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-# The MIT License (MIT)
-#
-# Copyright (c) 2020 Philippe Proulx <pproulx@efficios.com>
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-def test_members_el_invalid_type(config_fail_test):
-    config_fail_test()
-
-
-def test_members_el_member_label_invalid_type(config_fail_test):
-    config_fail_test()
-
-
-def test_members_el_member_unknown_prop(config_fail_test):
-    config_fail_test()
-
-
-def test_members_el_member_value_invalid_type(config_fail_test):
-    config_fail_test()
-
-
-def test_members_el_member_value_outside_range_signed(config_fail_test):
-    config_fail_test()
-
-
-def test_members_el_member_value_outside_range_unsigned(config_fail_test):
-    config_fail_test()
-
-
-def test_members_empty(config_fail_test):
-    config_fail_test()
-
-
-def test_members_invalid_type(config_fail_test):
-    config_fail_test()
-
-
-def test_members_no(config_fail_test):
-    config_fail_test()
-
-
-def test_members_overlap(config_fail_test):
-    config_fail_test()
-
-
-def test_unknown_prop(config_fail_test):
-    config_fail_test()
-
-
-def test_vt_invalid_type(config_fail_test):
-    config_fail_test()
-
-
-def test_vt_no(config_fail_test):
-    config_fail_test()
diff --git a/tests/config/yaml/2/test_fail_type_float.py b/tests/config/yaml/2/test_fail_type_float.py
deleted file mode 100644 (file)
index 915c4a4..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-# The MIT License (MIT)
-#
-# Copyright (c) 2020 Philippe Proulx <pproulx@efficios.com>
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-def test_align_0(config_fail_test):
-    config_fail_test()
-
-
-def test_align_3(config_fail_test):
-    config_fail_test()
-
-
-def test_align_invalid_type(config_fail_test):
-    config_fail_test()
-
-
-def test_bo_invalid_type(config_fail_test):
-    config_fail_test()
-
-
-def test_bo_invalid(config_fail_test):
-    config_fail_test()
-
-
-def test_size_exp_mant_wrong_sum(config_fail_test):
-    config_fail_test()
-
-
-def test_size_exp_no(config_fail_test):
-    config_fail_test()
-
-
-def test_size_invalid_type(config_fail_test):
-    config_fail_test()
-
-
-def test_size_mant_no(config_fail_test):
-    config_fail_test()
-
-
-def test_size_no(config_fail_test):
-    config_fail_test()
-
-
-def test_size_unknown_prop(config_fail_test):
-    config_fail_test()
-
-
-def test_unknown_prop(config_fail_test):
-    config_fail_test()
diff --git a/tests/config/yaml/2/test_fail_type_int.py b/tests/config/yaml/2/test_fail_type_int.py
deleted file mode 100644 (file)
index 0ade9fe..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-# The MIT License (MIT)
-#
-# Copyright (c) 2020 Philippe Proulx <pproulx@efficios.com>
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-def test_align_0(config_fail_test):
-    config_fail_test()
-
-
-def test_align_3(config_fail_test):
-    config_fail_test()
-
-
-def test_align_invalid_type(config_fail_test):
-    config_fail_test()
-
-
-def test_base_invalid_type(config_fail_test):
-    config_fail_test()
-
-
-def test_base_invalid(config_fail_test):
-    config_fail_test()
-
-
-def test_bo_invalid_type(config_fail_test):
-    config_fail_test()
-
-
-def test_bo_invalid(config_fail_test):
-    config_fail_test()
-
-
-def test_pm_invalid_type(config_fail_test):
-    config_fail_test()
-
-
-def test_pm_property_invalid(config_fail_test):
-    config_fail_test()
-
-
-def test_pm_type_invalid(config_fail_test):
-    config_fail_test()
-
-
-def test_pm_unknown_clock(config_fail_test):
-    config_fail_test()
-
-
-def test_signed_invalid_type(config_fail_test):
-    config_fail_test()
-
-
-def test_size_0(config_fail_test):
-    config_fail_test()
-
-
-def test_size_65(config_fail_test):
-    config_fail_test()
-
-
-def test_size_invalid_type(config_fail_test):
-    config_fail_test()
-
-
-def test_size_no(config_fail_test):
-    config_fail_test()
-
-
-def test_unknown_prop(config_fail_test):
-    config_fail_test()
diff --git a/tests/config/yaml/2/test_fail_type_string.py b/tests/config/yaml/2/test_fail_type_string.py
deleted file mode 100644 (file)
index 6b18ee5..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-# The MIT License (MIT)
-#
-# Copyright (c) 2020 Philippe Proulx <pproulx@efficios.com>
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-def test_unknown_prop(config_fail_test):
-    config_fail_test()
diff --git a/tests/config/yaml/2/test_fail_type_struct.py b/tests/config/yaml/2/test_fail_type_struct.py
deleted file mode 100644 (file)
index a958d8b..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-# The MIT License (MIT)
-#
-# Copyright (c) 2020 Philippe Proulx <pproulx@efficios.com>
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-def test_fields_field_invalid_identifier(config_fail_test):
-    config_fail_test()
-
-
-def test_fields_invalid_type(config_fail_test):
-    config_fail_test()
-
-
-def test_ma_0(config_fail_test):
-    config_fail_test()
-
-
-def test_ma_3(config_fail_test):
-    config_fail_test()
-
-
-def test_ma_invalid_type(config_fail_test):
-    config_fail_test()
-
-
-def test_unknown_prop(config_fail_test):
-    config_fail_test()
diff --git a/tests/config/yaml/2/test_fail_yaml.py b/tests/config/yaml/2/test_fail_yaml.py
deleted file mode 100644 (file)
index 58e52cc..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-# The MIT License (MIT)
-#
-# Copyright (c) 2020 Philippe Proulx <pproulx@efficios.com>
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-def test_invalid(config_fail_test):
-    config_fail_test()
index e9f9a2691701fde085abbc25433e4e43533efe5f..4b79bd0b1b6c6e6ff1b63ed8621a105b5cd34ca7 100644 (file)
@@ -26,13 +26,65 @@ import os.path
 import barectf
 
 
-@pytest.fixture
-def config_fail_test(yaml_cfg_path):
-    def func():
-        yaml_dir = os.path.dirname(yaml_cfg_path)
+def pytest_collect_file(parent, path):
+    yaml_ext = '.yaml'
 
-        with open(yaml_cfg_path) as f:
+    if path.ext != yaml_ext:
+        # not a YAML file: cancel
+        return
+
+    # At the end of this loop, if `path` is
+    # `/home/jo/barectf/tests/config/yaml/2/configs/fail/stream/pct-no.yaml`,
+    # for example, then `elems` is:
+    #
+    # * `pct-no.yaml`
+    # * `stream`
+    # * `fail`
+    path_str = str(path)
+    elems = []
+
+    while True:
+        elem = os.path.basename(path_str)
+
+        if elem == 'configs':
+            break
+
+        elems.append(elem)
+        path_str = os.path.dirname(path_str)
+
+    if 'fail' not in elems:
+        return
+
+    # create a unique test name
+    name = f'test-{"-".join(reversed(elems))}'.replace(yaml_ext, '')
+
+    # create the file node
+    return _YamlFile.from_parent(parent, fspath=path, name=name)
+
+
+class _YamlFile(pytest.File):
+    def __init__(self, parent, fspath, name):
+        super().__init__(parent=parent, fspath=fspath)
+        self._name = name
+
+    def collect(self):
+        # yield a single item
+        yield _YamlItem.from_parent(self, name=self._name)
+
+
+class _YamlItem(pytest.Item):
+    def __init__(self, parent, name):
+        super().__init__(parent=parent, name=name)
+
+    def runtest(self):
+        yaml_dir = self.fspath.dirname
+
+        with open(str(self.fspath)) as f:
             with pytest.raises(barectf._ConfigurationParseError):
                 barectf.configuration_from_file(f, inclusion_directories=[yaml_dir])
 
-    return func
+    def repr_failure(self, excinfo, style=None):
+        return f'`{self.fspath}` did not make barectf.configuration_from_file() raise `barectf._ConfigurationParseError`: {excinfo}.'
+
+    def reportinfo(self):
+        return self.fspath, None, self.name
This page took 0.036751 seconds and 4 git commands to generate.