示例#1
0
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
示例#2
0
    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)
示例#3
0
def upper_method():
    return get_parent_var('hidden_variable')