Skip to content

Commit fa12894

Browse files
Merge branch 'fix_pylint_reports_#37' into 'master'
Fix pylint reports #37 Closes #37 See merge request aleksandr-kotlyar/python_and_gitlab!77
2 parents d78c03b + bc343f3 commit fa12894

File tree

15 files changed

+65
-32
lines changed

15 files changed

+65
-32
lines changed

.gitlab/linter.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Pylint:
1414
allow_failure: true
1515
extends: .linter_template
1616
script:
17-
- pylint --rcfile=pylintrc $PWD | tee ./pylint/pylint.log || pylint-exit $?; rm __init__.py
17+
- pylint --rcfile=pylintrc $PWD | tee ./pylint/pylint.log
1818
after_script:
1919
- PYLINT_SCORE=$(sed -n 's/^Your code has been rated at \([-0-9.]*\)\/.*/\1/p' ./pylint/pylint.log)
2020
- echo $PYLINT_SCORE
@@ -26,11 +26,6 @@ Pylint:
2626
paths:
2727
- ./pylint/
2828

29-
Pylint Hard:
30-
extends: .linter_template
31-
script:
32-
- pylint --rcfile=pylintrc $PWD --disable=missing-function-docstring,missing-class-docstring,useless-super-delegation,line-too-long,global-statement,arguments-differ,invalid-name
33-
3429
#Quality Control:
3530
# allow_failure: false
3631
# stage: Merge Request

fixtures_browsers.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,28 @@
99

1010
@pytest.fixture(scope='function')
1111
def browser_func(choose_driver):
12+
"""Browser that closes after each test function or method."""
1213
yield choose_driver
1314
choose_driver.quit()
1415

1516

1617
@pytest.fixture(scope='class')
1718
def browser_class(choose_driver):
19+
"""Browser that closes after each test class."""
1820
yield choose_driver
1921
choose_driver.quit()
2022

2123

2224
@pytest.fixture(scope='module')
2325
def browser_module(choose_driver):
26+
"""Browser that closes after each test module."""
2427
yield choose_driver
2528
choose_driver.quit()
2629

2730

2831
@pytest.fixture(scope='session')
2932
def choose_driver(is_remote, t_browser):
33+
"""Remote or local browser selector fixture."""
3034
if is_remote:
3135
return remote_driver(t_browser)
3236
return custom_driver(t_browser)

fixtures_session.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
# pylint: disable=missing-function-docstring
12
import pytest
23

3-
from src.main.session import MySession, HttpbinApiSessionLevelOne, HttpbinApiSessionLevelTwo
4+
from src.main.session import ApiSession, HttpbinApiSessionLevelOne, HttpbinApiSessionLevelTwo
45

56

67
@pytest.fixture(scope='session', autouse=True)
7-
def api_session() -> MySession:
8-
with MySession() as session:
8+
def api_session() -> ApiSession:
9+
with ApiSession() as session:
910
yield session
1011

1112

src/main/allure_helpers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# pylint: disable=missing-function-docstring,missing-class-docstring
12
import json
23
import logging
34
from functools import wraps
@@ -71,15 +72,14 @@ def wrapper(*args, **kwargs):
7172
attachment_type=allure.attachment_type.JSON,
7273
extension='json')
7374

74-
except ValueError as error:
75+
except ValueError:
7576
logging.error('RESPONSE IN NOT JSON FORMAT')
7677
allure.attach(
7778
body=response.text.encode('utf8'),
7879
name=f'NOT JSON Response {response.status_code} {response.request.method} '
7980
f'{response.request.url}',
8081
attachment_type=allure.attachment_type.TEXT,
8182
extension='txt')
82-
raise error
8383
return response
8484

8585
return wrapper

src/main/file.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
def read_json(filename):
88
"""Read json and attach to allure as file."""
9-
with open(os.path.join(os.path.dirname(__file__), 'resources', filename)) as file:
9+
with open(os.path.join(os.getcwd(), 'resources', filename)) as file:
1010
schema = json.loads(file.read())
1111
allure.attach(body=json.dumps(schema, indent=2, ensure_ascii=False).encode('utf8'),
1212
name='Json schema', attachment_type=allure.attachment_type.JSON)

src/main/session.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# pylint: disable=arguments-differ
12
import json
23

34
import allure
@@ -6,22 +7,18 @@
67
from src.main.allure_helpers import allure_request_logger
78

89

9-
class MySession(Session):
10-
def __init__(self):
11-
super().__init__()
10+
class ApiSession(Session):
11+
"""Requests api session which Log request/response to allure attachments and console."""
1212

1313
@allure_request_logger
1414
def request(self, method, url, **kwargs) -> Response:
15-
""" Log request/response to allure and info"""
16-
1715
response = super().request(method=method, url=url, **kwargs)
1816

1917
return response
2018

2119

2220
class HttpbinApiSessionLevelOne(Session):
23-
def __init__(self, **kwargs):
24-
super().__init__(**kwargs)
21+
"""Requests api session which has hardcoded base_url."""
2522

2623
def request(self, method, url, **kwargs) -> Response:
2724
url = f'https://httpbin.org{url}'
@@ -30,8 +27,8 @@ def request(self, method, url, **kwargs) -> Response:
3027

3128

3229
class HttpbinApiSessionLevelTwo(Session):
33-
def __init__(self, **kwargs):
34-
super().__init__(**kwargs)
30+
"""Requests api session which has hardcoded base_url.
31+
And logs request/response into allure attachments."""
3532

3633
def request(self, method, url, **kwargs) -> Response:
3734
url = f'https://httpbin.org{url}'
@@ -40,19 +37,22 @@ def request(self, method, url, **kwargs) -> Response:
4037
try:
4138
allure.attach(
4239
body=url.encode('utf8'),
43-
name=f'Request {response.status_code} {method} {url}',
40+
name=f'Request {response.status_code} {response.request.method} '
41+
f'{response.request.url}',
4442
attachment_type=allure.attachment_type.TEXT,
4543
extension='txt')
4644
response.json()
4745
allure.attach(
4846
body=json.dumps(response.json(), indent=4, ensure_ascii=False).encode('utf8'),
49-
name=f'Response {response.status_code} {response.request.method} {response.request.url}',
47+
name=f'Response {response.status_code} {response.request.method} '
48+
f'{response.request.url}',
5049
attachment_type=allure.attachment_type.JSON,
5150
extension='json')
5251
except ValueError as error:
5352
allure.attach(
5453
body=response.text.encode('utf8'),
55-
name=f'NOT JSON Response {response.status_code} {response.request.method} {response.request.url}',
54+
name=f'NOT JSON Response {response.status_code} {response.request.method} '
55+
f'{response.request.url}',
5656
attachment_type=allure.attachment_type.TEXT,
5757
extension='txt')
5858
raise error

src/test/moretv/__init__.py

Whitespace-only changes.

src/test/moretv/main_page/__init__.py

Whitespace-only changes.

src/test/old_ctc/__init__.py

Whitespace-only changes.

src/test/old_ctc/tvprogram/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)