I have a module A who looks like the following:

```
import unittest2

def check_function():
    # performs actions and returns True or False
    return smth

CHECK = check_function()

class A(unittest2.TestCase):

    @unittest2.skipIf(CHECK, "skip message 1")
    def test_1(self):
        # test check

    @unittest2.skipIf(CHECK, "skip message 2")
    def test_2(self):
        # test check

```

Module A is being imported by another module, called B. 
When is the global variable CHECK initialized? At import? At class instantiation? 

I need to have the CHECK variable set each time class A is called. How can I achieve this?

EDIT:
I have tried the following (which might be what I am looking for), but CHECK is not set at all inside setUpClass (it stays False, no matter what check\_function() returns).

```
import unittest2

def check_function():
    # performs actions and returns True or False
    return smth

CHECK = False

class A(unittest2.TestCase):

    global CHECK

    @classmethod
    def setUpClass(cls):
        CHECK = check_function()

    @unittest2.skipIf(CHECK, "skip message 1")
    def test_1(self):
        # test check

    @unittest2.skipIf(CHECK, "skip message 2")
    def test_2(self):
        # test check

```

Any ideas of how to set CHECK once, each time the test is invoked?

EDIT:
check\_function() is certainly called once, but I don't understand why unittest2.skipIf does not "see" the value set in setUpClass, and sticks to the False value set at declaration?

SOLUTION:

The final skeletopn of the code looks like this:

```
import unittest2

def check_function():
    # performs checks and returns True or False
    return smth

class A(unittest2.TestCase):

    CHECK = check_function()

    @unittest2.skipIf(CHECK, "skip message 1")
    def test_1(self):
        # do tests
        self.assertTrue(True)

    @unittest2.skipIf(CHECK, "skip message 1")
    def test_2(self):
        # do tests
        self.assertTrue(True)

```