justinmoon / junction

UI For Using Hardware Wallets With Bitcoin Core
MIT License
60 stars 13 forks source link

tidy up resources in a way that unittest do not raise ResourceWarning #26

Closed k9ert closed 5 years ago

k9ert commented 5 years ago

Removes these ResourceWarnings

----------------------------------------------------------------------
Ran 11 tests in 4.614s

OK (skipped=1)
Exception ignored in: <bound method Popen.__del__ of <subprocess.Popen object at 0x7f4a7e0de400>>
Traceback (most recent call last):
  File "/home/kim/.pyenv/versions/3.6.6/lib/python3.6/subprocess.py", line 766, in __del__
    ResourceWarning, source=self)
ResourceWarning: subprocess 15558 is still running
Exception ignored in: <socket.socket fd=3, family=AddressFamily.AF_INET, type=2049, proto=6, laddr=('127.0.0.1', 51662), raddr=('127.0.0.1', 18443)>
ResourceWarning: unclosed <socket.socket fd=3, family=AddressFamily.AF_INET, type=2049, proto=6, laddr=('127.0.0.1', 51662), raddr=('127.0.0.1', 18443)>

There are lots of other ResourceWarnings and i tried to fix them via using a ContextManager as described in https://stackoverflow.com/posts/54612520/revisions You can have a look in my testing_context_manager branch. https://github.com/k9ert/junction/commit/5684c0724b4a92c7802e23564122b5d7e52eb06d For some reason the wallet_rpc.importmulti-call resisted that solution heavily, that's why 4 tests broke and i didn't included that in this PR. Are you happy with a context-manager in general for your RPC-class? Would you be happy to use pytest? Why don't you merge the testing-branch to master? I'd worry about diverging stuff too much with too man y branches.

justinmoon commented 5 years ago

Awesome. I'll take a look at this tomorrow. Was getting those warnings, too, and hadn't investigated yet. Really appreciate the help!

k9ert commented 5 years ago

Resolved via rebase and force-push to avoid the merge-commit. http://kernowsoul.com/blog/2012/06/20/4-ways-to-avoid-merge-commits-in-git/

k9ert commented 5 years ago

Seems to be no longer happening in develop. Is the testing branch still relevant?