<p>I was trying to run python tests in order to test a PR. I used this command to run <code>p2p</code> tests:</p>
<pre><code>[amirreza@localhost bitcoin]$ ./test/functional/test_runner.py test/functional/p2p*
</code></pre>
<p>It produces lots of <code>ResourceWarning</code> warnings. And the result of the tests is this:</p>
<pre><code>TEST                            | STATUS    | DURATION

p2p_add_connections.py          | ✖ Failed  | 7 s
p2p_addr_relay.py               | ✖ Failed  | 18 s
p2p_addrfetch.py                | ✖ Failed  | 2 s
p2p_addrv2_relay.py             | ✖ Failed  | 1 s
p2p_block_sync.py               | ✖ Failed  | 1 s
p2p_blockfilters.py             | ✖ Failed  | 17 s
p2p_blocksonly.py               | ✖ Failed  | 10 s
p2p_compactblocks.py            | ✖ Failed  | 6 s
p2p_compactblocks_blocksonly.py | ✖ Failed  | 2 s
p2p_compactblocks_hb.py         | ✖ Failed  | 9 s
p2p_disconnect_ban.py           | ✖ Failed  | 2 s
p2p_dns_seeds.py                | ✖ Failed  | 36 s
p2p_dos_header_tree.py          | ✖ Failed  | 2 s
p2p_eviction.py                 | ✖ Failed  | 5 s
p2p_feefilter.py                | ✖ Failed  | 7 s
p2p_filter.py                   | ✖ Failed  | 4 s
p2p_fingerprint.py              | ✖ Failed  | 1 s
p2p_getaddr_caching.py          | ✖ Failed  | 21 s
p2p_getdata.py                  | ✖ Failed  | 1 s
p2p_i2p_ports.py                | ✖ Failed  | 3 s
p2p_ibd_txrelay.py              | ✖ Failed  | 2 s
p2p_invalid_block.py            | ✖ Failed  | 2 s
p2p_invalid_locator.py          | ✖ Failed  | 2 s
p2p_invalid_messages.py         | ✖ Failed  | 50 s
p2p_invalid_tx.py               | ✖ Failed  | 8 s
p2p_leak.py                     | ✖ Failed  | 7 s
p2p_leak_tx.py                  | ✖ Failed  | 2 s
p2p_message_capture.py          | ✖ Failed  | 2 s
p2p_nobloomfilter_messages.py   | ✖ Failed  | 3 s
p2p_node_network_limited.py     | ✖ Failed  | 11 s
p2p_permissions.py              | ✖ Failed  | 11 s
p2p_ping.py                     | ✖ Failed  | 2 s
p2p_segwit.py                   | ✖ Failed  | 131 s
p2p_sendheaders.py              | ✖ Failed  | 16 s
p2p_timeouts.py                 | ✖ Failed  | 2 s
p2p_tx_download.py              | ✖ Failed  | 38 s
p2p_unrequested_blocks.py       | ✖ Failed  | 5 s

ALL                             | ✖ Failed  | 449 s (accumulated) 
Runtime: 188 s
</code></pre>
<p>So I think the tests are failed due to my computer limited resources. Is this correct?
If yes, is there any way to suppress these kind of failures and don't count them as failing test?</p>
<p>As @PieterWuille suggested, I tried running one single test file. So I did this:</p>
<pre><code>[amirreza@localhost bitcoin]$ ./test/functional/p2p_filter.py 
</code></pre>
<p>And this is the result:</p>
<pre><code>/usr/local/lib/python3.12/configparser.py:733: ResourceWarning: unclosed file &lt;_io.TextIOWrapper name='/home/amirreza/git_repos/bitcoin/test/config.ini' mode='r' encoding='UTF-8'&gt;
  self._read(f, source)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
2022-08-14T15:45:45.288000Z TestFramework (INFO): Initializing test directory /tmp/bitcoin_func_test_e4o2s8j6
2022-08-14T15:45:46.149000Z TestFramework (INFO): Test filter size limits
2022-08-14T15:45:46.149000Z TestFramework (INFO): Check that too large filter is rejected
2022-08-14T15:45:46.204000Z TestFramework (INFO): Check that max size filter is accepted
2022-08-14T15:45:46.309000Z TestFramework (INFO): Check that filter with too many hash functions is rejected
2022-08-14T15:45:46.361000Z TestFramework (INFO): Check that filter with max hash functions is accepted
2022-08-14T15:45:46.413000Z TestFramework (INFO): Check that max size data element to add to the filter is accepted
2022-08-14T15:45:46.465000Z TestFramework (INFO): Check that too large data element to add to the filter is rejected
2022-08-14T15:45:46.568000Z TestFramework (INFO): Test BIP 37 for a node with fRelay = True (default)
2022-08-14T15:45:46.622000Z TestFramework (INFO): Check that we receive merkleblock and tx if the filter matches a tx in a block
2022-08-14T15:45:46.634000Z TestFramework (INFO): Check that we only receive a merkleblock if the filter does not match a tx in a block
2022-08-14T15:45:46.659000Z TestFramework (INFO): Check that we not receive a tx if the filter does not match a mempool tx
2022-08-14T15:45:46.782000Z TestFramework (INFO): Check that we receive a tx if the filter matches a mempool tx
2022-08-14T15:45:46.839000Z TestFramework (INFO): Check that after deleting filter all txs get relayed again
2022-08-14T15:45:47.378000Z TestFramework (INFO): Check that request for filtered blocks is ignored if no filter is set
2022-08-14T15:45:47.461000Z TestFramework (INFO): Check that sending &quot;filteradd&quot; if no filter is set is treated as misbehavior
2022-08-14T15:45:47.513000Z TestFramework (INFO): Check that division-by-zero remote crash bug [CVE-2013-5700] is fixed
2022-08-14T15:45:47.672000Z TestFramework (INFO): Test BIP 37 for a node with fRelay = False
2022-08-14T15:45:47.776000Z TestFramework (INFO): Check that a node with fRelay set to false does not receive invs until the filter is set
2022-08-14T15:45:47.895000Z TestFramework (INFO): Check that we receive merkleblock and tx if the filter matches a tx in a block
2022-08-14T15:45:47.908000Z TestFramework (INFO): Check that we only receive a merkleblock if the filter does not match a tx in a block
2022-08-14T15:45:47.936000Z TestFramework (INFO): Check that we not receive a tx if the filter does not match a mempool tx
2022-08-14T15:45:48.059000Z TestFramework (INFO): Check that we receive a tx if the filter matches a mempool tx
2022-08-14T15:45:48.116000Z TestFramework (INFO): Check that after deleting filter all txs get relayed again
2022-08-14T15:45:48.639000Z TestFramework (INFO): Check that request for filtered blocks is ignored if no filter is set
2022-08-14T15:45:48.720000Z TestFramework (INFO): Check that sending &quot;filteradd&quot; if no filter is set is treated as misbehavior
2022-08-14T15:45:48.772000Z TestFramework (INFO): Check that division-by-zero remote crash bug [CVE-2013-5700] is fixed
2022-08-14T15:45:48.927000Z TestFramework (INFO): Check that a node with bloom filters enabled services p2p mempool messages
2022-08-14T15:45:49.189000Z TestFramework (INFO): Stopping nodes
2022-08-14T15:45:49.291000Z TestFramework (INFO): Cleaning up /tmp/bitcoin_func_test_e4o2s8j6 on exit
2022-08-14T15:45:49.291000Z TestFramework (INFO): Tests successful
sys:1: ResourceWarning: unclosed &lt;socket.socket fd=10, family=2, type=1, proto=6, laddr=('127.0.0.1', 43502), raddr=('127.0.0.1', 15831)&gt;
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/usr/local/lib/python3.12/asyncio/selector_events.py:835: ResourceWarning: unclosed transport &lt;_SelectorSocketTransport fd=10&gt;
  _warn(f&quot;unclosed transport {self!r}&quot;, ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
</code></pre>

CC BY-SA 4.0
2022-08-12T18:13:24.813Z
Try running with `-j1` to only run once test at a time.
Pieter Wuille
CC BY-SA 4.0
2022-08-12T18:25:30.980Z
@PieterWuille  Thanks, but there's still lots of failed tests after running with one job.
Amir reza Riahi
CC BY-SA 4.0
2022-08-12T18:32:59.057Z
What kind of system is this? OS/CPU/RAM?
Pieter Wuille
CC BY-SA 4.0
2022-08-13T05:02:45.297Z
@PieterWuille core i3 cpu, 8 GB ram, on fedora 31
Amir reza Riahi
CC BY-SA 4.0
2022-08-13T17:06:59.553Z
Can you post the actual errors you're getting? Have you tried running the individual tests (not through test_runner.py)?
Pieter Wuille
CC BY-SA 4.0
2022-08-14T15:52:18.790Z
@PieterWuille I edited the question. Tried an individual test.
Amir reza Riahi
CC BY-SA 4.0
2022-08-14T15:53:35.180Z
@PieterWuille Today I run all tests in a different machine and all of them passed without any warning. So now I'm sure the problem is with my system.
Amir reza Riahi
<bitcoin-core-development><python><functional-test>
How to ignore ResourceWarnings during running tests?
Amir reza Riahi
# How to ignore ResourceWarnings during running tests?

(Asked by: username_0 on 2022-08-12)

I was trying to run python tests in order to test a PR. I used this command to run p2p tests:
[amirreza@localhost bitcoin]$ ./test/functional/test_runner.py test/functional/p2p*

It produces lots of ResourceWarning warnings. And the result of the tests is this:
TEST                            | STATUS    | DURATION

p2p_add_connections.py          | ✖ Failed  | 7 s
p2p_addr_relay.py               | ✖ Failed  | 18 s
p2p_addrfetch.py                | ✖ Failed  | 2 s
p2p_addrv2_relay.py             | ✖ Failed  | 1 s
p2p_block_sync.py               | ✖ Failed  | 1 s
p2p_blockfilters.py             | ✖ Failed  | 17 s
p2p_blocksonly.py               | ✖ Failed  | 10 s
p2p_compactblocks.py            | ✖ Failed  | 6 s
p2p_compactblocks_blocksonly.py | ✖ Failed  | 2 s
p2p_compactblocks_hb.py         | ✖ Failed  | 9 s
p2p_disconnect_ban.py           | ✖ Failed  | 2 s
p2p_dns_seeds.py                | ✖ Failed  | 36 s
p2p_dos_header_tree.py          | ✖ Failed  | 2 s
p2p_eviction.py                 | ✖ Failed  | 5 s
p2p_feefilter.py                | ✖ Failed  | 7 s
p2p_filter.py                   | ✖ Failed  | 4 s
p2p_fingerprint.py              | ✖ Failed  | 1 s
p2p_getaddr_caching.py          | ✖ Failed  | 21 s
p2p_getdata.py                  | ✖ Failed  | 1 s
p2p_i2p_ports.py                | ✖ Failed  | 3 s
p2p_ibd_txrelay.py              | ✖ Failed  | 2 s
p2p_invalid_block.py            | ✖ Failed  | 2 s
p2p_invalid_locator.py          | ✖ Failed  | 2 s
p2p_invalid_messages.py         | ✖ Failed  | 50 s
p2p_invalid_tx.py               | ✖ Failed  | 8 s
p2p_leak.py                     | ✖ Failed  | 7 s
p2p_leak_tx.py                  | ✖ Failed  | 2 s
p2p_message_capture.py          | ✖ Failed  | 2 s
p2p_nobloomfilter_messages.py   | ✖ Failed  | 3 s
p2p_node_network_limited.py     | ✖ Failed  | 11 s
p2p_permissions.py              | ✖ Failed  | 11 s
p2p_ping.py                     | ✖ Failed  | 2 s
p2p_segwit.py                   | ✖ Failed  | 131 s
p2p_sendheaders.py              | ✖ Failed  | 16 s
p2p_timeouts.py                 | ✖ Failed  | 2 s
p2p_tx_download.py              | ✖ Failed  | 38 s
p2p_unrequested_blocks.py       | ✖ Failed  | 5 s

ALL                             | ✖ Failed  | 449 s (accumulated) 
Runtime: 188 s

So I think the tests are failed due to my computer limited resources. Is this correct?
If yes, is there any way to suppress these kind of failures and don't count them as failing test?
As @PieterWuille suggested, I tried running one single test file. So I did this:
[amirreza@localhost bitcoin]$ ./test/functional/p2p_filter.py 

And this is the result:
/usr/local/lib/python3.12/configparser.py:733: ResourceWarning: unclosed file <_io.TextIOWrapper name='/home/amirreza/git_repos/bitcoin/test/config.ini' mode='r' encoding='UTF-8'>
  self._read(f, source)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
2022-08-14T15:45:45.288000Z TestFramework (INFO): Initializing test directory /tmp/bitcoin_func_test_e4o2s8j6
2022-08-14T15:45:46.149000Z TestFramework (INFO): Test filter size limits
2022-08-14T15:45:46.149000Z TestFramework (INFO): Check that too large filter is rejected
2022-08-14T15:45:46.204000Z TestFramework (INFO): Check that max size filter is accepted
2022-08-14T15:45:46.309000Z TestFramework (INFO): Check that filter with too many hash functions is rejected
2022-08-14T15:45:46.361000Z TestFramework (INFO): Check that filter with max hash functions is accepted
2022-08-14T15:45:46.413000Z TestFramework (INFO): Check that max size data element to add to the filter is accepted
2022-08-14T15:45:46.465000Z TestFramework (INFO): Check that too large data element to add to the filter is rejected
2022-08-14T15:45:46.568000Z TestFramework (INFO): Test BIP 37 for a node with fRelay = True (default)
2022-08-14T15:45:46.622000Z TestFramework (INFO): Check that we receive merkleblock and tx if the filter matches a tx in a block
2022-08-14T15:45:46.634000Z TestFramework (INFO): Check that we only receive a merkleblock if the filter does not match a tx in a block
2022-08-14T15:45:46.659000Z TestFramework (INFO): Check that we not receive a tx if the filter does not match a mempool tx
2022-08-14T15:45:46.782000Z TestFramework (INFO): Check that we receive a tx if the filter matches a mempool tx
2022-08-14T15:45:46.839000Z TestFramework (INFO): Check that after deleting filter all txs get relayed again
2022-08-14T15:45:47.378000Z TestFramework (INFO): Check that request for filtered blocks is ignored if no filter is set
2022-08-14T15:45:47.461000Z TestFramework (INFO): Check that sending "filteradd" if no filter is set is treated as misbehavior
2022-08-14T15:45:47.513000Z TestFramework (INFO): Check that division-by-zero remote crash bug [CVE-2013-5700] is fixed
2022-08-14T15:45:47.672000Z TestFramework (INFO): Test BIP 37 for a node with fRelay = False
2022-08-14T15:45:47.776000Z TestFramework (INFO): Check that a node with fRelay set to false does not receive invs until the filter is set
2022-08-14T15:45:47.895000Z TestFramework (INFO): Check that we receive merkleblock and tx if the filter matches a tx in a block
2022-08-14T15:45:47.908000Z TestFramework (INFO): Check that we only receive a merkleblock if the filter does not match a tx in a block
2022-08-14T15:45:47.936000Z TestFramework (INFO): Check that we not receive a tx if the filter does not match a mempool tx
2022-08-14T15:45:48.059000Z TestFramework (INFO): Check that we receive a tx if the filter matches a mempool tx
2022-08-14T15:45:48.116000Z TestFramework (INFO): Check that after deleting filter all txs get relayed again
2022-08-14T15:45:48.639000Z TestFramework (INFO): Check that request for filtered blocks is ignored if no filter is set
2022-08-14T15:45:48.720000Z TestFramework (INFO): Check that sending "filteradd" if no filter is set is treated as misbehavior
2022-08-14T15:45:48.772000Z TestFramework (INFO): Check that division-by-zero remote crash bug [CVE-2013-5700] is fixed
2022-08-14T15:45:48.927000Z TestFramework (INFO): Check that a node with bloom filters enabled services p2p mempool messages
2022-08-14T15:45:49.189000Z TestFramework (INFO): Stopping nodes
2022-08-14T15:45:49.291000Z TestFramework (INFO): Cleaning up /tmp/bitcoin_func_test_e4o2s8j6 on exit
2022-08-14T15:45:49.291000Z TestFramework (INFO): Tests successful
sys:1: ResourceWarning: unclosed 
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/usr/local/lib/python3.12/asyncio/selector_events.py:835: ResourceWarning: unclosed transport <_SelectorSocketTransport fd=10>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback

**Tags:** bitcoin-core-development, python, functional-test

> **Comments:**
> **username_1**: Try running with `-j1` to only run once test at a time.  
> **username_0**: @PieterWuille  Thanks, but there's still lots of failed tests after running with one job.  
> **username_1**: What kind of system is this? OS/CPU/RAM?  
> **username_0**: @PieterWuille core i3 cpu, 8 GB ram, on fedora 31  
> **username_1**: Can you post the actual errors you're getting? Have you tried running the individual tests (not through test_runner.py)?  
> **username_0**: @PieterWuille I edited the question. Tried an individual test.  
> **username_0**: @PieterWuille Today I run all tests in a different machine and all of them passed without any warning. So now I'm sure the problem is with my system.  

---

## 0 answers

