def test_read_from_env(): saved = os.environ try: os.environ = FakeEnviron(None) check_equal(env.read_from_env('FOOBAR'), 0) check_equal(env.read_uint_from_env('FOOBAR'), r_uint(0)) check_equal(env.read_float_from_env('FOOBAR'), 0.0) # os.environ = FakeEnviron('') check_equal(env.read_from_env('FOOBAR'), 0) check_equal(env.read_uint_from_env('FOOBAR'), r_uint(0)) check_equal(env.read_float_from_env('FOOBAR'), 0.0) # os.environ = FakeEnviron('???') check_equal(env.read_from_env('FOOBAR'), 0) check_equal(env.read_uint_from_env('FOOBAR'), r_uint(0)) check_equal(env.read_float_from_env('FOOBAR'), 0.0) # os.environ = FakeEnviron('1') check_equal(env.read_from_env('FOOBAR'), 1) check_equal(env.read_uint_from_env('FOOBAR'), r_uint(1)) check_equal(env.read_float_from_env('FOOBAR'), 1.0) # os.environ = FakeEnviron('12345678') check_equal(env.read_from_env('FOOBAR'), 12345678) check_equal(env.read_uint_from_env('FOOBAR'), r_uint(12345678)) check_equal(env.read_float_from_env('FOOBAR'), 12345678.0) # os.environ = FakeEnviron('1234B') check_equal(env.read_from_env('FOOBAR'), 1234) check_equal(env.read_uint_from_env('FOOBAR'), r_uint(1234)) check_equal(env.read_float_from_env('FOOBAR'), 1234.0) # os.environ = FakeEnviron('1.5') check_equal(env.read_float_from_env('FOOBAR'), 1.5) # os.environ = FakeEnviron('1.5Kb') check_equal(env.read_from_env('FOOBAR'), 1536) check_equal(env.read_uint_from_env('FOOBAR'), r_uint(1536)) check_equal(env.read_float_from_env('FOOBAR'), 0.0) # os.environ = FakeEnviron('1.5mB') check_equal(env.read_from_env('FOOBAR'), int(1.5 * 1024 * 1024)) check_equal(env.read_uint_from_env('FOOBAR'), r_uint(1.5 * 1024 * 1024)) check_equal(env.read_float_from_env('FOOBAR'), 0.0) # os.environ = FakeEnviron('1.5g') check_equal(env.read_from_env('FOOBAR'), int(1.5 * 1024 * 1024 * 1024)) check_equal(env.read_uint_from_env('FOOBAR'), r_uint(1.5 * 1024 * 1024 * 1024)) check_equal(env.read_float_from_env('FOOBAR'), 0.0) # finally: os.environ = saved
def test_read_from_env(): saved = os.environ try: os.environ = FakeEnviron(None) check_equal(env.read_from_env('FOOBAR'), 0) check_equal(env.read_uint_from_env('FOOBAR'), r_uint(0)) check_equal(env.read_float_from_env('FOOBAR'), 0.0) # os.environ = FakeEnviron('') check_equal(env.read_from_env('FOOBAR'), 0) check_equal(env.read_uint_from_env('FOOBAR'), r_uint(0)) check_equal(env.read_float_from_env('FOOBAR'), 0.0) # os.environ = FakeEnviron('???') check_equal(env.read_from_env('FOOBAR'), 0) check_equal(env.read_uint_from_env('FOOBAR'), r_uint(0)) check_equal(env.read_float_from_env('FOOBAR'), 0.0) # os.environ = FakeEnviron('1') check_equal(env.read_from_env('FOOBAR'), 1) check_equal(env.read_uint_from_env('FOOBAR'), r_uint(1)) check_equal(env.read_float_from_env('FOOBAR'), 1.0) # os.environ = FakeEnviron('12345678') check_equal(env.read_from_env('FOOBAR'), 12345678) check_equal(env.read_uint_from_env('FOOBAR'), r_uint(12345678)) check_equal(env.read_float_from_env('FOOBAR'), 12345678.0) # os.environ = FakeEnviron('1234B') check_equal(env.read_from_env('FOOBAR'), 1234) check_equal(env.read_uint_from_env('FOOBAR'), r_uint(1234)) check_equal(env.read_float_from_env('FOOBAR'), 1234.0) # os.environ = FakeEnviron('1.5') check_equal(env.read_float_from_env('FOOBAR'), 1.5) # os.environ = FakeEnviron('1.5Kb') check_equal(env.read_from_env('FOOBAR'), 1536) check_equal(env.read_uint_from_env('FOOBAR'), r_uint(1536)) check_equal(env.read_float_from_env('FOOBAR'), 0.0) # os.environ = FakeEnviron('1.5mB') check_equal(env.read_from_env('FOOBAR'), int(1.5*1024*1024)) check_equal(env.read_uint_from_env('FOOBAR'), r_uint(1.5*1024*1024)) check_equal(env.read_float_from_env('FOOBAR'), 0.0) # os.environ = FakeEnviron('1.5g') check_equal(env.read_from_env('FOOBAR'), int(1.5*1024*1024*1024)) check_equal(env.read_uint_from_env('FOOBAR'), r_uint(1.5*1024*1024*1024)) check_equal(env.read_float_from_env('FOOBAR'), 0.0) # finally: os.environ = saved
def nursery_size_from_env(): return env.read_from_env('PYPY_GENERATIONGC_NURSERY')
def post_setup(self): # More stuff that needs to be initialized when the GC is already # fully working. (Only called by gctransform/framework for now.) from rpython.memory.gc import env self.DEBUG = env.read_from_env('PYPY_GC_DEBUG')
def post_setup(self): # More stuff that needs to be initialized when the GC is already # fully working. (Only called by gctransform/framework for now.) from rpython.memory.gc import env self.DEBUG = env.read_from_env("PYPY_GC_DEBUG")