-
Notifications
You must be signed in to change notification settings - Fork 5
Add test vol. 2 #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
DmitryTokyo
wants to merge
23
commits into
python-testing-sandbox:master
Choose a base branch
from
DmitryTokyo:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
6d29261
Add code.py
DmitryTokyo c571e74
Create test and conftest
DmitryTokyo 146fe88
Add travis.yml
DmitryTokyo 43dfd6f
Update .gitignore
DmitryTokyo a34a744
Rename main module
DmitryTokyo a8ded56
Update requirements.txt
DmitryTokyo aeb727d
Add _set_listed_at test
DmitryTokyo e02da08
Add tests
DmitryTokyo a257d97
Add .flake8
DmitryTokyo 887ef40
Rename travis
DmitryTokyo 24273dd
Fix flake8
DmitryTokyo 250ccab
Fix .travis.yml
DmitryTokyo 4a432d1
Update test_skip_exceptions_to_reraise
DmitryTokyo 335eee0
Update README.md (add badge)
DmitryTokyo 09664ce
Update test_fetch_detailed_pull_requests. Fix test_set_listed_at
DmitryTokyo 2707883
Update .flake8 ignore
DmitryTokyo 49878b1
Update travis
DmitryTokyo d9a55a2
Removed print
DmitryTokyo 5b204d2
Move to test folder
DmitryTokyo 5807e7f
Create Makefile
DmitryTokyo e667515
Update requirements.txt
DmitryTokyo cf6e319
Update requirements.txt
DmitryTokyo 514cf85
Add init
DmitryTokyo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| [flake8] | ||
| max-line-length = 120 | ||
| exclude = venv, code_2.py, code.py | ||
| ignore = D103, TAE001, D100, D104 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -348,3 +348,4 @@ make.exe | |
|
|
||
| *.json | ||
| *sqlite3 | ||
| .idea | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| language: python | ||
| python: | ||
| - "3.9" | ||
| install: | ||
| - pip install -r requirements.txt | ||
| script: | ||
| - make style | ||
| - make test | ||
| after_success: | ||
| - bash <(curl -s https://codecov.io/bash) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| style: | ||
| flake8 . | ||
|
|
||
| test: | ||
| pytest --cov=code_2 --cov-branch tests/test_code.py |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| import ast | ||
| import datetime | ||
| import io | ||
| import re | ||
| from typing import Iterable, Any, Optional, Generator | ||
|
|
||
| from PIL import Image | ||
| from requests import get | ||
| from requests.exceptions import MissingSchema | ||
|
|
||
|
|
||
| def chunks(some_list: list, chunk_size: int) -> Generator: | ||
| for chunk_num in range(0, len(some_list), chunk_size): | ||
| yield some_list[chunk_num:chunk_num + chunk_size] | ||
|
|
||
|
|
||
| def flat(some_list: list[list]) -> list: | ||
| return [item for sublist in some_list for item in sublist] | ||
|
|
||
|
|
||
| def has_recursive_calls(funcdef) -> bool: | ||
| return bool([ | ||
| n for n in ast.walk(funcdef) | ||
| if ( | ||
| isinstance(n, ast.Call) | ||
| and isinstance(n.func, ast.Name) | ||
| and n.func.id == funcdef.name | ||
| ) | ||
| ]) | ||
|
|
||
|
|
||
| def parse_iso_datetime(iso_datetime: str) -> Optional[datetime.datetime]: | ||
| if iso_datetime.endswith('Z'): | ||
| iso_datetime = iso_datetime[:-1] | ||
| try: | ||
| return datetime.datetime.fromisoformat(iso_datetime) | ||
| except ValueError: | ||
| return None | ||
|
|
||
|
|
||
| def get_image_height_in_pixels(url: str) -> Optional[int]: | ||
| try: | ||
| img_data = get(url).content | ||
| except MissingSchema: | ||
| return None | ||
| im = Image.open(io.BytesIO(img_data)) | ||
| return im.size[1] | ||
|
|
||
|
|
||
| def if_logs_has_any_of_commands(log: list[str], commands: list[str]) -> bool: | ||
| is_section_present = False | ||
| for required_command in commands: | ||
| for base_command in log: | ||
| if ( | ||
| base_command.startswith(f'{required_command} ') | ||
| or f' {required_command} ' in base_command | ||
| or base_command == required_command | ||
| ): | ||
| is_section_present = True | ||
| break | ||
| return is_section_present | ||
|
|
||
|
|
||
| def extract_all_constants_from_ast(ast_tree: ast.AST) -> list[str]: | ||
| return list({n.s for n in ast.walk(ast_tree) if isinstance(n, ast.Str)}) | ||
|
|
||
|
|
||
| def is_camel_case_word(word: str) -> bool: | ||
| uppercase_letters_amount = re.subn(r'[A-Z]', '', word)[1] | ||
| lowercase_letters_amount = re.subn(r'[a-z]', '', word)[1] | ||
| return bool( | ||
| (lowercase_letters_amount and uppercase_letters_amount >= 2) | ||
| or re.findall(r'[a-z][A-Z]', word), | ||
| ) | ||
|
|
||
|
|
||
| def split_camel_case_words(camel_cased_word: str) -> list[str]: | ||
| words_start_indexes = [m.start(0) for m in re.finditer(r'[A-Z]', camel_cased_word)] | ||
| if words_start_indexes[0] > 0: | ||
| words_start_indexes.insert(0, 0) | ||
| if words_start_indexes[-1] < len(camel_cased_word): | ||
| words_start_indexes.append(len(camel_cased_word)) | ||
| words = [] | ||
| for word_start_index, word_end_index in zip(words_start_indexes, words_start_indexes[1:]): | ||
| words.append(camel_cased_word[word_start_index:word_end_index].lower()) | ||
| return words | ||
|
|
||
|
|
||
| def is_path_in_exclude_list(path: str, exclude: list[str]) -> bool: | ||
| return any(e in path for e in exclude) | ||
|
|
||
|
|
||
| def get_full_class_name(obj: Any) -> str: | ||
| module = obj.__class__.__module__ | ||
| if module is None or module == str.__class__.__module__: | ||
| return obj.__class__.__name__ | ||
| return module + '.' + obj.__class__.__name__ | ||
|
|
||
|
|
||
| def max_with_default(items: Iterable, default: Optional = None): | ||
| default = default or 0 | ||
| items = list(items) | ||
| if not items and default is not None: | ||
| return default | ||
| return max(items) | ||
|
|
||
|
|
||
| def is_python_class_name(name: str) -> bool: | ||
| return name[0] == name[0].upper() and name[1:] == name[1:].lower() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import functools | ||
| import sys | ||
| from contextlib import contextmanager | ||
| from io import StringIO | ||
|
|
||
|
|
||
| @contextmanager | ||
| def does_not_raise(): | ||
| yield | ||
|
|
||
|
|
||
| def redirect_stdout(decorated_function): | ||
| @functools.wraps(decorated_function) | ||
| def wrapper(*args): | ||
| sys.stdout = StringIO() | ||
| sys.stdout = sys.__stdout__ | ||
| decorated_function(*args) | ||
| return wrapper |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: излишнее по флэйку. разве не достаточно только одного flake8==3.9.2?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Я добавил расширения из рабочего проекта. Единственное что, сейчас убрал расширешиние с аннотациями, тк я в тестовом файле нигде не использую