diff options
author | jonathanmetzman <31354670+jonathanmetzman@users.noreply.github.com> | 2020-12-07 10:50:11 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-07 10:50:11 -0800 |
commit | b0b99d5ccdf5e2e49cfe3138fbcf64e6fef6ea7f (patch) | |
tree | 4afa704c82330c785a468ecfe5097314e7b06365 /infra/test_helpers.py | |
parent | a24cebec02a0c97247bef31963d5f5fadbaa4ebf (diff) | |
download | oss-fuzz-b0b99d5ccdf5e2e49cfe3138fbcf64e6fef6ea7f.tar.gz |
Cifuzz external build (#4656)
* Support building fuzzers for projects outside of OSS-Fuzz
* Use retry wrapper
* Fix some tests.
Diffstat (limited to 'infra/test_helpers.py')
-rw-r--r-- | infra/test_helpers.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/infra/test_helpers.py b/infra/test_helpers.py new file mode 100644 index 000000000..5a9a4d582 --- /dev/null +++ b/infra/test_helpers.py @@ -0,0 +1,27 @@ +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""Contains convenient helpers for writing tests.""" + +import os +from unittest import mock + + +def patch_environ(testcase_obj, env=None): + """Patch environment.""" + if env is None: + env = {} + + patcher = mock.patch.dict(os.environ, env) + testcase_obj.addCleanup(patcher.stop) + patcher.start() |