Giter Site home page Giter Site logo

Comments (5)

epogrebnyak avatar epogrebnyak commented on July 22, 2024

Eventually, the test with https://docs.python.org/3/library/unittest.mock.html#mock-open I did not finish it, it seems the function can digest any kinds of arguments.

The test with temp file in b141b15 is really preferred one: it is quicker to write and easier to maintain, and allows to test for (3) functionality too.

@pytest.fixture    
def temp_path():
    with NamedTemporaryFile() as f:
        abspath = f.name
    p = Path(abspath)    
    p.write_text("abc\n123")
    return p

class Test_open_csv:    

    def test_on_string_argument_raises_TypeError(self):
        path_string = 'abc.csv'
        with pytest.raises(TypeError):
            open_csv(path_string)

    def test_on_Path_runs_with_no_error(self, temp_path):
        assert open_csv(temp_path)

    def test_on_Path_provides_readable_input(self, temp_path):
        with open_csv(temp_path) as f:            
            assert f.readlines() == ['abc\n', '123'] 

from parser-rosstat-kep.

epogrebnyak avatar epogrebnyak commented on July 22, 2024

@bakakaldsas, I need you final "yes, sure" kind of approval to close this 👍

from parser-rosstat-kep.

bakakaldsas avatar bakakaldsas commented on July 22, 2024

Yes, this is definitelly better.

from parser-rosstat-kep.

bakakaldsas avatar bakakaldsas commented on July 22, 2024

So for the sake of cleaner test file the multiple test cases should be removed only leaving the preferred version?

from parser-rosstat-kep.

epogrebnyak avatar epogrebnyak commented on July 22, 2024

from parser-rosstat-kep.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.