How to use is_not_file method in autotest

Best Python code snippet using autotest_python

rypc_client.py

Source:rypc_client.py Github

copy

Full Screen

...22 print(f'./example.txt')23 for i in Command:24 print(f'{i.value}')25 print(f'{"="*20} {"="*20}')26def is_not_file(file_path):27 if Path(file_path).is_file():28 return False29 else:30 print("AYYO there's no such file yo!\n==========================\n")31 return True32def user_input_handler(proxy, user_input_command):33 print(34 f"Command: {user_input_command} - {Command(user_input_command).value}")35 if(user_input_command == Command.E_AES.value):36 file_path = input(TEXT_INPUT.PLAINTEXT.value)37 if is_not_file(file_path):38 return39 password = input(TEXT_INPUT.PASSWORD.value)40 data_file = None41 if file_path.endswith('.txt'):42 with open(file_path, 'r') as f:43 data_file = f.read()44 proxy.root.encrypt_AES(data_file, file_path, password)45 print(TEXT_INPUT.SUCESS.value)46 elif(user_input_command == Command.D_AES.value):47 file_path = input(TEXT_INPUT.CIPHERTEXT.value)48 if is_not_file(file_path):49 return50 password = input(TEXT_INPUT.PASSWORD.value)51 data_file = None52 if file_path.endswith('.txt'):53 with open(file_path, 'r') as f:54 data_file = f.read()55 proxy.root.decrypt_AES(data_file, file_path, password)56 print(TEXT_INPUT.SUCESS.value)57 elif(user_input_command == Command.E_DES.value):58 file_path = input(TEXT_INPUT.PLAINTEXT.value)59 data_file = None60 if is_not_file(file_path):61 return62 proxy.root.encrypt_DES(data_file, file_path)63 print(TEXT_INPUT.SUCESS.value)64 elif(user_input_command == Command.D_DES.value):65 file_path = input(TEXT_INPUT.CIPHERTEXT.value)66 data_file = None67 if is_not_file(file_path):68 return69 proxy.root.decrypt_DES(data_file, file_path)70 print(TEXT_INPUT.SUCESS.value)71 elif(user_input_command == Command.E_RC4.value):72 file_path = input(TEXT_INPUT.CIPHERTEXT.value)73 if is_not_file(file_path):74 return75 password = input(TEXT_INPUT.PASSWORD.value)76 data_file = None77 if file_path.endswith('.mp4') or file_path.endswith('.jpg') or file_path.endswith('.png'):78 with open(file_path, 'rb') as f:79 data_file = base64.b64encode(f.read())80 elif file_path.endswith('.txt'):81 with open(file_path, 'r') as f:82 data_file = f.read()83 proxy.root.encrypt_RC4(data_file, file_path, password)84 print(TEXT_INPUT.SUCESS.value)85 elif(user_input_command == Command.D_RC4.value):86 file_path = input(TEXT_INPUT.CIPHERTEXT.value)87 if is_not_file(file_path):88 return89 password = input(TEXT_INPUT.PASSWORD.value)90 data_file = None91 if file_path.endswith('.enc'):92 with open(file_path, 'r') as f:93 data_file = f.read()94 proxy.root.decrypt_RC4(data_file, file_path, password)95 print(TEXT_INPUT.SUCESS.value)96 elif(user_input_command == Command.QUIT.value):97 time.sleep(2)98 proxy.close()99 100def main():101 config = {'allow_public_attrs': True}...

Full Screen

Full Screen

__init__.py

Source:__init__.py Github

copy

Full Screen

1from typing import Union2from pathlib import Path345def check_type(var_name: str, var: object, expected_type: Union[type, object]) -> None:6 """7 A handy little typechecker - use to strictly enforce types.8 """910 # Do some junk to check expected_type - is it a normal base type, or some abomination from the typing module?11 # https://stackoverflow.com/a/4947118712 if hasattr(expected_type, "__origin__"):13 # Assume of type Union for the moment, update this if I ever get errors from here.14 # Here, expected_type.__args__ contains the base types (string, int, etc.) we need, and can be passed into15 # isinstance below.16 type_expected = expected_type.__args__17 if len(type_expected) == 1:18 type_name = type_expected[0].__name__19 else:20 type_name = ", ".join([t.__name__ for t in type_expected[:-1]]) + f" or {type_expected[-1].__name__}"21 else:22 type_expected = expected_type23 type_name = type_expected.__name__2425 if not isinstance(var, type_expected):26 raise TypeError(f"Variable {var_name} is of type {type(var).__name__}; expected {type_name}.")272829def check_exists(path: Union[str, Path], name: str, file: bool = True):30 """Check whether the given path exists. This is a noisy utility function, and will raise an Exception if the file31 or directory does not exist."""32 ExceptionType = FileNotFoundError if file else NotADirectoryError33 p = Path(path)34 is_not_file = file and not p.is_file()35 if not p.exists() or is_not_file:36 raise ExceptionType(f"{name} not found at {str(p.absolute())}.")373839def check_sanity_int(var_name: str, var: int):40 """A simple sanity checker for row/column/layout integer variables. Must be integer and > 0."""41 check_type(var_name, var, int)42 if var < 1:43 raise ValueError(f"{var_name} must be greater than 0. Received {var_name} = {var}.") ...

Full Screen

Full Screen

test_allowed_files.py

Source:test_allowed_files.py Github

copy

Full Screen

...4@pytest.fixture()5def is_file(mocker):6 mocker.patch(IS_FILE_FUNCTION, return_value=True)7@pytest.fixture()8def is_not_file(mocker):9 mocker.patch(IS_FILE_FUNCTION, return_value=False)10def test_ignores_with_custom_regex_expression(is_file):11 assert not is_allowed_files('name.py', ignore=['name'])12 # word13 assert not is_allowed_files('name.py', ignore=[r'\w+'])14 # starts with 'n'15 assert not is_allowed_files('name.py', ignore=[r'^n'])16 # ends with 'e'17 assert not is_allowed_files('name.py', ignore=[r'.*e$'])18def test_default_ignored(is_file):19 assert not is_allowed_files('__init__.py')20 assert not is_allowed_files('__py_file__.py')21 assert not is_allowed_files('_my_private_file.py')22def test_not_allows_when_is_not_file(is_not_file):23 assert not is_allowed_files('not_a_file')24def test_allows_when_is_a_file(is_file):...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful