def test_scope_var(): for _ in range(10): hidden_variable = random.randint(0, 1000000) test = upper_method() assert hidden_variable == test del hidden_variable test = upper_method() assert test is None assert get_parent_var('pytest', global_ok=True) == pytest
def test_scope_var(self): for _ in range(10): hidden_variable = random.randint(0, 1000000) test = self.upper_method() self.assertEqual(hidden_variable, test) del hidden_variable test = self.upper_method() self.assertIsNone(test) self.assertEqual(get_parent_var('unittest', global_ok=True), unittest)
def upper_method(): return get_parent_var('hidden_variable')