Pytest: DeprecationWarning: use tobytes instead of tostring

Created on 11 Oct 2018  路  2Comments  路  Source: pytest-dev/pytest

I've had pytest pinned at 3.6.4 in one of my repos while waiting for #3749 to be resolved. It looks like it's been fixed since 3.8.1. w00t, good work!

However, all versions since 3.8.1 have introduced a new issue.

/projects/kevlar/kevlar/dump.py:108: DeprecationWarning: tostring() is deprecated. Use tobytes() instead.
  for read in dump(args.reads, refr, args.pair_mode, logstream=args.logfile):
/projects/kevlar/kevlar/dump.py:108: DeprecationWarning: tostring() is deprecated. Use tobytes() instead.
  for read in dump(args.reads, refr, args.pair_mode, logstream=args.logfile):
/projects/kevlar/kevlar/dump.py:108: DeprecationWarning: tostring() is deprecated. Use tobytes() instead.
  for read in dump(args.reads, refr, args.pair_mode, logstream=args.logfile):
/projects/kevlar/kevlar/dump.py:108: DeprecationWarning: tostring() is deprecated. Use tobytes() instead.
  for read in dump(args.reads, refr, args.pair_mode, logstream=args.logfile):
/projects/kevlar/kevlar/dump.py:108: DeprecationWarning: tostring() is deprecated. Use tobytes() instead.
  for read in dump(args.reads, refr, args.pair_mode, logstream=args.logfile):

/projects/kevlar/kevlar/tests/test_dump.py:38: DeprecationWarning: tostring() is deprecated. Use tobytes() instead.
  records = [r for r in kevlar.dump.dump(bamstream)]
/projects/kevlar/kevlar/tests/test_dump.py:38: DeprecationWarning: tostring() is deprecated. Use tobytes() instead.
  records = [r for r in kevlar.dump.dump(bamstream)]
/projects/kevlar/kevlar/tests/test_dump.py:38: DeprecationWarning: tostring() is deprecated. Use tobytes() instead.
  records = [r for r in kevlar.dump.dump(bamstream)]
/projects/kevlar/kevlar/tests/test_dump.py:38: DeprecationWarning: tostring() is deprecated. Use tobytes() instead.
  records = [r for r in kevlar.dump.dump(bamstream)]
/projects/kevlar/kevlar/tests/test_dump.py:38: DeprecationWarning: tostring() is deprecated. Use tobytes() instead.
  records = [r for r in kevlar.dump.dump(bamstream)]
/projects/kevlar/kevlar/tests/test_dump.py:38: DeprecationWarning: tostring() is deprecated. Use tobytes() instead.
  records = [r for r in kevlar.dump.dump(bamstream)]
/projects/kevlar/kevlar/tests/test_dump.py:38: DeprecationWarning: tostring() is deprecated. Use tobytes() instead.
  records = [r for r in kevlar.dump.dump(bamstream)]
/projects/kevlar/kevlar/tests/test_dump.py:38: DeprecationWarning: tostring() is deprecated. Use tobytes() instead.
  records = [r for r in kevlar.dump.dump(bamstream)]

/projects/kevlar/kevlar/dump.py:108: DeprecationWarning: tostring() is deprecated. Use tobytes() instead.
  for read in dump(args.reads, refr, args.pair_mode, logstream=args.logfile):
/projects/kevlar/kevlar/dump.py:108: DeprecationWarning: tostring() is deprecated. Use tobytes() instead.
  for read in dump(args.reads, refr, args.pair_mode, logstream=args.logfile):
/projects/kevlar/kevlar/dump.py:108: DeprecationWarning: tostring() is deprecated. Use tobytes() instead.
  for read in dump(args.reads, refr, args.pair_mode, logstream=args.logfile):
/projects/kevlar/kevlar/dump.py:108: DeprecationWarning: tostring() is deprecated. Use tobytes() instead.
  for read in dump(args.reads, refr, args.pair_mode, logstream=args.logfile):

/projects/kevlar/kevlar/tests/test_dump.py:66: DeprecationWarning: tostring() is deprecated. Use tobytes() instead.
  records = [r for r in kevlar.dump.dump(bamstream, refr, pairmode=mode)]

/projects/kevlar/kevlar/tests/test_dump.py:66: DeprecationWarning: tostring() is deprecated. Use tobytes() instead.
  records = [r for r in kevlar.dump.dump(bamstream, refr, pairmode=mode)]
/projects/kevlar/kevlar/tests/test_dump.py:66: DeprecationWarning: tostring() is deprecated. Use tobytes() instead.
  records = [r for r in kevlar.dump.dump(bamstream, refr, pairmode=mode)]

Reverting back to 3.6.4 fixed the issue. This is happening on Ubuntu 16.04. Unfortunately it may be a bit until I can provide a small reproducible example.

Most helpful comment

Thanks for the response.

The code directly referenced by the warning messages doesn't call any tostring method, anywhere in the entire module. It's likely calls to another module, pysam, that are problematic. In any case, thanks for letting me know how to silence the warnings, I'll see if I can come up with an example for the pysam developers.

All 2 comments

Hi @standage,

pytest 3.8 now shows deprecation warnings by default, so it is not an issue with pytest per-se.

You can fix the code, or ignore the warnings by adding this to your pytest.ini file:

[pytest]
filterwarnings=
    ignore:tostring.*is deprecated

I'm closing this for now, but feel free to follow up if you have any other questions. 馃憤

Thanks for the response.

The code directly referenced by the warning messages doesn't call any tostring method, anywhere in the entire module. It's likely calls to another module, pysam, that are problematic. In any case, thanks for letting me know how to silence the warnings, I'll see if I can come up with an example for the pysam developers.

Was this page helpful?
0 / 5 - 0 ratings