Skip to content

Commit

Permalink
escape the regexes
Browse files Browse the repository at this point in the history
  • Loading branch information
lgray authored Oct 17, 2023
1 parent 9c8a810 commit 8df1111
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions tests/test_nanoevents.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,20 +162,20 @@ def test_missing_eventIds_error():
path = os.path.abspath("tests/samples/missing_luminosityBlock.root") + ":Events"
with pytest.raises(
RuntimeError,
match="There are missing event ID fields: ['luminosityBlock'] \n\n\
The event ID fields ['run', 'luminosityBlock', 'event'] are necessary to perform sub-run identification \
(e.g. for corrections and sub-dividing data during different detector conditions),\
to cross-validate MC and Data (i.e. matching events for comparison), and to generate event displays. \
It's advised to never drop these branches from the dataformat.\n\n\
This error can be demoted to a warning by setting the class level variable error_missing_event_ids to False.",
match=r"There are missing event ID fields\: \[\'\luminosityBlock\'\] \n\n\
The event ID fields \[\'run\'\, \'luminosityBlock\'\, \'event\'\] are necessary to perform sub-run identification \
\(e\.g\. for corrections and sub\-dividing data during different detector conditions\)\,\
to cross-validate MC and Data \(i\.e\. matching events for comparison\)\, and to generate event displays\. \
It\'s advised to never drop these branches from the dataformat\.\n\n\
This error can be demoted to a warning by setting the class level variable error\_missing\_event\_ids to False\.",
):
factory = NanoEventsFactory.from_root(path, schemaclass=NanoAODSchema)
factory.events()


def test_missing_eventIds_warning():
path = os.path.abspath("tests/samples/missing_luminosityBlock.root") + ":Events"
with pytest.warns(RuntimeWarning, match="Missing event_ids : ['luminosityBlock']"):
with pytest.warns(RuntimeWarning, match=r"Missing event_ids \: \[\'luminosityBlock\'\]"):
NanoAODSchema.error_missing_event_ids = False
factory = NanoEventsFactory.from_root(path, schemaclass=NanoAODSchema)
factory.events()

0 comments on commit 8df1111

Please sign in to comment.