vendredi 19 janvier 2018

Python file to write testing

I am trying to start myself with Python testing and one of the objectives is to verify that a file is written in the correct format. I am trying to make a very simple example work to start off:

class TestDataImport(unittest.TestCase):
@pytest.fixture(autouse=True)
def test_save_data(self, tmpdir):
    p = tmpdir.join("hello.txt")
    p.write("content")
    assert p.read() == "content"
    assert len(tmpdir.listdir()) == 1

I am executing it from using the python -m unitest....

I am getting the following error:

c:\Users\cgafa\Desktop\ML\>python -m unittest data_preparation_test
..E
======================================================================
ERROR: test_save_data (data_preparation_test.TestDataImport)
----------------------------------------------------------------------
TypeError: test_save_data() missing 1 required positional argument: 'tmpdir'

----------------------------------------------------------------------
Ran 3 tests in 0.016s

FAILED (errors=1)

Any ideas please?

Thanks

Aucun commentaire:

Enregistrer un commentaire