<commit_before>import os
import threading

import pytest
from paramiko import RSAKey, SFTPServer, SFTP, Transport

from .loop import LoopSocket
from .stub_sftp import StubServer, StubSFTPServer
from .util import _support


# TODO: not a huge fan of conftest.py files, see if we can move these somewhere
# 'nicer'.


def make_sftp_folder(client):
    """
    Create some non-existing, new folder on the given SFTP connection.
    """
    path = os.environ.get('TEST_FOLDER', 'temp-testing000')
    # TODO: this is disgusting and old, replace with something smarter/simpler
    for i in range(1000):
        path = path[:-3] + '%03d' % i
        try:
            client.mkdir(path)
            return path
        except (IOError, OSError):
            pass


# TODO: apply at module or session level
# TODO: roll in SFTP folder setup and teardown?
# NOTE: This is defined here for use by both SFTP (normal & 'big') suites.
@pytest.fixture
def sftp():
    """
    Set up an in-memory SFTP server, returning its corresponding SFTPClient.
    """<commit_msg>Scope SFTP client/server fixture to be session-level for now<commit_after>import os
import threading

import pytest
from paramiko import RSAKey, SFTPServer, SFTP, Transport

from .loop import LoopSocket
from .stub_sftp import StubServer, StubSFTPServer
from .util import _support


# TODO: not a huge fan of conftest.py files, see if we can move these somewhere
# 'nicer'.


def make_sftp_folder(client):
    """
    Create some non-existing, new folder on the given SFTP connection.
    """
    path = os.environ.get('TEST_FOLDER', 'temp-testing000')
    # TODO: this is disgusting and old, replace with something smarter/simpler
    for i in range(1000):
        path = path[:-3] + '%03d' % i
        try:
            client.mkdir(path)
            return path
        except (IOError, OSError):
            pass


# TODO: apply at module or session level
# TODO: roll in SFTP folder setup and teardown?
# NOTE: This is defined here for use by both SFTP (normal & 'big') suites.
@pytest.fixture(scope='session')
def sftp():
    """
    Set up an in-memory SFTP server, returning its corresponding SFTPClient.
    """
{'fraction_non_alphanumeric': 0.08885819521178637, 'fraction_numerical': 0.009208103130755065, 'mean_word_length': 3.107750472589792, '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': '5241499', 'n_tokens_mistral': 681, 'n_tokens_neox': 667, 'n_words': 256}