<commit_before>import mock

import pypuppetdb


def test_connect_api():
    puppetdb = pypuppetdb.connect()
    assert puppetdb.version == 'v4'


@mock.patch('pypuppetdb.api.requests.Session.close')
def test_connect_with_statement(session_close):
    with pypuppetdb.connect() as puppetdb:
        assert puppetdb.version == 'v4'

    assert session_close.called
<commit_msg>test that calling the disconnect() method causes HTTP sessions to close<commit_after>import mock

import pypuppetdb


@mock.patch('pypuppetdb.api.requests.Session.close')
def test_connect_api(session_close):
    puppetdb = pypuppetdb.connect()
    assert puppetdb.version == 'v4'

    puppetdb.disconnect()
    assert session_close.called


@mock.patch('pypuppetdb.api.requests.Session.close')
def test_connect_with_statement(session_close):
    with pypuppetdb.connect() as puppetdb:
        assert puppetdb.version == 'v4'

    assert session_close.called

{'fraction_non_alphanumeric': 0.09860664523043944, 'fraction_numerical': 0.004287245444801715, 'mean_word_length': 4.730061349693251, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5135300', 'n_tokens_mistral': 315, 'n_tokens_neox': 303, 'n_words': 60}