Skip to content

Ressourcewarning: unclosed file in UnitTest #368

Closed
@b-m-f

Description

@b-m-f

This is my test:

import httpretty
import unittest
import requests
from unittest import TestCase

file_cache_directory = ".testcache"

class Test(TestCase):
    @httpretty.activate
    def test(self):
        httpretty.register_uri(
            httpretty.GET,
            "https://httpbin.org/ip",
            body='{"origin": "127.0.0.1"}',
        )
        resp = requests.get("https://httpbin.org/ip")

        self.assertIn("127.0.0.1", resp.text)

Which generates the following error while still executing successfully:

httpretty/core.py:495: ResourceWarning: unclosed file <_io.BufferedRandom name=4>
  self.fd = FakeSockFile()

HTTPretty VERSION: 0.9.6
Python VERSION: 3.6.7
OS: 64bit Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions