Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DeprecationWarning: You passed a bytestring as filenames #530

Closed
nedbat opened this issue Nov 7, 2016 · 10 comments
Closed

DeprecationWarning: You passed a bytestring as filenames #530

nedbat opened this issue Nov 7, 2016 · 10 comments
Labels
bug Something isn't working

Comments

@nedbat
Copy link
Owner

nedbat commented Nov 7, 2016

Originally reported by Anonymous


I am using coverage (version 4.0) with nose (1.3.7) for my test suite on Travis CI.

Every time I am using the coverage script (erase, run, report, ...) I get this error raised:

coverage run --rcfile=.coveragerc -m nose -c .noserc
/home/travis/virtualenv/python2.7.12/lib/python2.7/site-packages/coverage/config.py:27: DeprecationWarning: You passed a bytestring as `filenames`. This will not work on Python 3. Use `cp.read_file()` or switch to using Unicode strings across the board.
  return configparser.RawConfigParser.read(self, filename, **kwargs)

I do not understand what it means and where it comes from ...

I run this command:

coverage run --rcfile=.coveragerc -m nose -c .noserc

My coverage configuration file is:

[report]
;fail_under = 100
exclude_lines =
    pragma: no cover
    def __repr__
    if self.debug:
    if settings.DEBUG
    raise AssertionError
    raise NotImplementedError
    if 0:
    if __name__ == .__main__.:

[run]
branch = True
source =
    alignak

omit =
    */mock/*
    */nose/*

[paths]
source =
    /home/travis/build/Alignak-monitoring/alignak/alignak

My nose configuration file is:

[nosetests]
verbosity=3
; Uncomment to have the stdout
;nocapture=1
; Uncomment to remove the python logger from output (except for console logs)
;nologcapture=1

; Only 1 running test process
processes=1
; Process timeout is 5 minutes
process-timeout=300
; Restart worker process (avoid memory leak)
process-restartworker=1

@nedbat
Copy link
Owner Author

nedbat commented Nov 7, 2016

Original comment by mohierf (Bitbucket: mohierf, GitHub: mohierf)


Sorry, but I was not logged-in when I created the issue.

@nedbat
Copy link
Owner Author

nedbat commented Nov 7, 2016

@mohierf What version of Python are you running under? Can you try upgrading to the latest version of coverage.py (4.2)?

@nedbat
Copy link
Owner Author

nedbat commented Nov 7, 2016

Original comment by mohierf (Bitbucket: mohierf, GitHub: mohierf)


I am running Python 2.6 and 2.7. I will give a try with the 4.2 version and report if any problem here.

@nedbat
Copy link
Owner Author

nedbat commented Nov 7, 2016

Original comment by mohierf (Bitbucket: mohierf, GitHub: mohierf)


I used the 4.2 version on my Travis build. No warning with python2.6. But with python2.7 I still have the same warning message

@nedbat
Copy link
Owner Author

nedbat commented Nov 8, 2016

@mohierf Can you give me a link to one of your failing Travis builds? It seems like there's a warning flag enabled that isn't on by default?

@nedbat
Copy link
Owner Author

nedbat commented Nov 8, 2016

Original comment by mohierf (Bitbucket: mohierf, GitHub: mohierf)


Of course: https://travis-ci.org/Alignak-monitoring/alignak/jobs/173902832

In this build:

  • I run coverage with the nose module,
  • I DO NOT run coverage combine
  • I run coverage report

You will note that the report result seems not ok: 13 % !

With my current test suite, where I run nosetests with its coverage plugin I get 70% !

@nedbat
Copy link
Owner Author

nedbat commented Nov 8, 2016

Thanks, I can see that this line is in the Travis job:

$ export PYTHONWARNINGS=all

Aren't you bothered by the slew of other warnings you're getting? Why enable all these warnings? I don't need Python to tell me that my Python 2 code will behave differently in Python 3. I've already accounted for that.

@nedbat
Copy link
Owner Author

nedbat commented Nov 9, 2016

Turns out the warning is from a configparser backport. I've switched the imports to avoid that module, and now the warning is gone. Fixed in f8e9d62f1412 (bb)

@nedbat
Copy link
Owner Author

nedbat commented Nov 9, 2016

Original comment by mohierf (Bitbucket: mohierf, GitHub: mohierf)


Thank you for the feedback and the hint for Python warnings, I did not know about this Travis feature. It seems that it is enabled as a default ... but I do not know yet why. I will investigate this.

@nedbat
Copy link
Owner Author

nedbat commented Dec 27, 2016

This fix was released as part of Coverage.py 4.3.

@nedbat nedbat closed this as completed Dec 27, 2016
@nedbat nedbat added minor bug Something isn't working labels Jun 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant