Code Monkey home page Code Monkey logo

Comments (8)

jiangk avatar jiangk commented on July 22, 2024

The readme says the project has 100% test coverage, but when I run the tests I still get 99%. It comes down to a few lines in Util's is_connection_dropped that are platform specific and therefore don't/can't get executed on a single platform.

Do you think it would be beneficial to add some tests that mock out the poll/select behavior, so 100% coverage can be reached on any platform?

from urllib3.

shazow avatar shazow commented on July 22, 2024

Unfortunately there is a lot of platform-specific code in urllib3 (grep for "# Python" and "# Platform"), and I'm not sure that mocking it out would actually improve how thoroughly it's exercised.

If the goal is just to make coverage smarter about what blocks should be ignored, then take a look at the .coveragerc file. We already do this all over the place where relevant, though I think the Util may be missing a case in some platform or another. Hmm would be nice if we could make coverage ignore only the platform-specific blocks not relevant to your current platform. Not sure that's an option, though.

By the way, which platform are you running on? Here's my output on Py27.

$ nosetests
........................................................................
Name                     Stmts   Miss  Cover   Missing
------------------------------------------------------
urllib3                     21      0   100%   
urllib3._collections        45      0   100%   
urllib3.connectionpool     168      0   100%   
urllib3.contrib              0      0   100%   
urllib3.exceptions          26      0   100%   
urllib3.filepost            37      0   100%   
urllib3.poolmanager         57      0   100%   
urllib3.request             23      0   100%   
urllib3.response            80      0   100%   
urllib3.util                89      0   100%   
------------------------------------------------------
TOTAL                      546      0   100%   
----------------------------------------------------------------------
Ran 72 tests in 0.778s

from urllib3.

jiangk avatar jiangk commented on July 22, 2024

Ah, that makes sense. I was wondering how 100% coverage was possible with the platform specific stuff.

I'm running OS X. The lines reported as not covered are related to select.poll(), which according to the comments is not supported in OS X.

$ nosetests
........................................................................
Name                     Stmts   Miss  Cover   Missing
------------------------------------------------------
urllib3                     21      0   100%   
urllib3._collections        45      0   100%   
urllib3.connectionpool     168      0   100%   
urllib3.contrib              0      0   100%   
urllib3.exceptions          26      0   100%   
urllib3.filepost            37      0   100%   
urllib3.poolmanager         57      0   100%   
urllib3.request             23      0   100%   
urllib3.response            80      0   100%   
urllib3.util                89      5    94%   247-252
------------------------------------------------------
TOTAL                      546      5    99%   
----------------------------------------------------------------------
Ran 72 tests in 0.780s

Perhaps we should add that block to coverage.rc?

from urllib3.

shazow avatar shazow commented on July 22, 2024

Hmm at this point I feel like we should omit the entire is_connection_dropped helper from coverage, since basically every line is dependent on a different platform. What do you think?

from urllib3.

jiangk avatar jiangk commented on July 22, 2024

That makes sense. It's certainly nicer than having # Platform-specific on every other line :)

from urllib3.

shazow avatar shazow commented on July 22, 2024

Should be fixed now, can you confirm? :)

from urllib3.

jiangk avatar jiangk commented on July 22, 2024

Not excluding the helper yet--I think you need to escape the parentheses in the regex: .* # \(No coverage\)

from urllib3.

shazow avatar shazow commented on July 22, 2024

Mmm good point, want to fix it? :)

I can't verify it myself. :(

from urllib3.

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.