def test_register_and_parse_flags_with_usage_exits_on_only_check_args(self): done = app._register_and_parse_flags_with_usage.done try: app._register_and_parse_flags_with_usage.done = False with self.assertRaises(SystemExit): app._register_and_parse_flags_with_usage( argv=['./program', '--only_check_args']) finally: app._register_and_parse_flags_with_usage.done = done
def test_register_and_parse_flags_with_usage_exits_on_second_run(self): with self.assertRaises(SystemError): app._register_and_parse_flags_with_usage()
JAX_MODE = False # Flags for controlling test_teed behavior. flags.DEFINE_bool('vary_seed', False, ('Whether to vary the PRNG seed unpredictably. ' 'With --runs_per_test=N, produces N iid runs.')) flags.DEFINE_string('fixed_seed', None, ('PRNG seed to initialize every test with. ' 'Takes precedence over --vary-seed when both appear.')) # Unlike bazel, `pytest` doesn't invoke `tf.test.run()` (which parses flags), so # for external developers using pytest we just parse the flags directly. if 'pytest' in sys.modules: app._register_and_parse_flags_with_usage() # pylint: disable=protected-access class TestCase(tf.test.TestCase, parameterized.TestCase): """Class to provide TensorFlow Probability specific test features.""" def maybe_static(self, x, is_static): """If `not is_static`, return placeholder_with_default with unknown shape. Args: x: A `Tensor` is_static: a Python `bool`; if True, x is returned unchanged. If False, x is wrapped with a tf1.placeholder_with_default with fully dynamic shape. Returns: maybe_static_x: `x`, possibly wrapped with in a `placeholder_with_default` of unknown shape.
def pytest_collection_finish(session): # Unlike bazel, `pytest` doesn't invoke `tf.test.run()` (which parses flags), # so for external developers using pytest we just parse the flags directly. absl_flags = session.config.getoption("absl_flag", default=[]) app._register_and_parse_flags_with_usage(["test.py"] + absl_flags) # pylint: disable=protected-access