




from unittest.mock import Mock, patch

from file_transfer.send_file import send_file

@patch('socket.socket'				)
@patch('builtins.open'				)
def    UpperCAmelCase_				( __UpperCAmelCase		:      int     ,     __UpperCAmelCase		:      int				)   ->					Union[str, Any]:
      # ===== initialization =====
      SCREAMING_SNAKE_CASE_      		=     Mock()
      SCREAMING_SNAKE_CASE_      		=     conn, Mock()
      SCREAMING_SNAKE_CASE_      		=     iter([1, None]				)
      SCREAMING_SNAKE_CASE_      		=     lambda __UpperCAmelCase				: next(__UpperCAmelCase				)

      # ===== invoke =====
      send_file(filename='mytext.txt'     ,     testing=__UpperCAmelCase				)

      # ===== ensurance =====
      sock.assert_called_once()
      sock.return_value.bind.assert_called_once()
      sock.return_value.listen.assert_called_once()
      sock.return_value.accept.assert_called_once()
      conn.recv.assert_called_once()

      file.return_value.__enter__.assert_called_once()
      file.return_value.__enter__.return_value.read.assert_called()

      conn.send.assert_called_once()
      conn.close.assert_called_once()
      sock.return_value.shutdown.assert_called_once()
      sock.return_value.close.assert_called_once()







import re
from pathlib import Path
from unittest import TestCase

import pytest


@pytest.mark.integration
class     _a							(	UpperCAmelCase__     ):






  """simple docstring"""





  def  _UpperCAmelCase  (  self		,		_UpperCAmelCase			)      ->			Dict:

     with open(_UpperCAmelCase		,		encoding='utf-8'			) as input_file:
        UpperCamelCase_						=  re.compile(R'(?!.*\b(?:encoding|rb|w|wb|w+|wb+|ab|ab+)\b)(?<=\s)(open)\((.*)\)'			)
        UpperCamelCase_						=  input_file.read()
        UpperCamelCase_						=  regexp.search(_UpperCAmelCase			)

     return match




  def  _UpperCAmelCase  (  self		,		_UpperCAmelCase			)      ->			Dict:

     with open(_UpperCAmelCase		,		encoding='utf-8'			) as input_file:
        UpperCamelCase_						=  re.compile(R'#[^\r\n]*print\(|\"[^\r\n]*print\(|\"\"\".*?print\(.*?\"\"\"|(print\()'		,		re.DOTALL			)
        UpperCamelCase_						=  input_file.read()
        # use `re.finditer` to handle the case where the ignored groups would be matched first by `re.search`
        UpperCamelCase_						=  regexp.finditer(_UpperCAmelCase			)

     UpperCamelCase_						=  [match for match in matches if match is not None and match.group(1			) is not None]
     return matches[0] if matches else None




  def  _UpperCAmelCase  (  self			)      ->			List[str]:
     UpperCamelCase_						=  Path('./datasets'			)
     UpperCamelCase_						=  list(dataset_paths.absolute().glob('**/*.py'			)			)

     for dataset in dataset_files:
        if self._no_encoding_on_file_open(str(_UpperCAmelCase			)			):
           raise AssertionError(f"""open(...) must use utf-8 encoding in {dataset}"""			)




  def  _UpperCAmelCase  (  self			)      ->			Optional[int]:
     UpperCamelCase_						=  Path('./datasets'			)
     UpperCamelCase_						=  list(dataset_paths.absolute().glob('**/*.py'			)			)

     for dataset in dataset_files:
        if self._no_print_statements(str(_UpperCAmelCase			)			):
           raise AssertionError(f"""print statement found in {dataset}. Use datasets.logger/logging instead."""			)





