0
@pytest.mark.django_db
class TestClass():

    def do_setup(self):
        # do setup

    def test_a(self):
        # do something

    def test_b(self):
        # do something

test_a および test_b テスト ケースを実行する前に、do_setup() を呼び出す必要があります。私は pytest-django フレームワークを使用しています。

親切に助けてください。

前もって感謝します

4

1 に答える 1

0

利用方法・機能レベル設定の分解

def setup_method(self, method):
    """ setup any state tied to the execution of the given method in a
    class.  setup_method is invoked for every test method of a class.
    """

def teardown_method(self, method):
    """ teardown any state that was previously setup with a setup_method
    call.
    """

http://pytest.org/latest/xunit_setup.html#method-and-function-level-setup-teardownを参照してください

于 2016-02-06T05:58:47.753 に答える