Skip to content

Commit 1bce704

Browse files
authored
unicode support (fixes #69 via #71)
unicode fixes
1 parent 906ac18 commit 1bce704

File tree

10 files changed

+26
-23
lines changed

10 files changed

+26
-23
lines changed

allure-behave/features/description.feature

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
@wip
21
Feature: Description
32

43
Scenario: Use description

allure-behave/features/scenario.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ Feature: Scenario
3131
Given passed step
3232
"""
3333
When I run behave with allure formatter
34-
Then allure report has a scenario with name "Scenario"
34+
Then allure report has a scenario with name "Scenario"

allure-behave/features/steps/behave_steps.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,18 @@
99

1010

1111
@given(u'feature definition')
12-
def feature_definition(context):
13-
parser = Parser()
12+
@given(u'feature definition {lang}')
13+
def feature_definition(context, **kwargs):
14+
parser = Parser(language=kwargs.get('lang', None))
1415
context.feature_definition = parser.parse(context.text)
1516

1617

1718
@when(u'I run behave with allure formatter')
18-
def run_behave_with_allure(context):
19+
@when(u'I run behave with allure formatter with options "{args}"')
20+
def run_behave_with_allure(context, **kwargs):
1921
cmd_args = '-v -f allure_behave.formatter:AllureFormatter -f pretty'
20-
config = Configuration(command_args=cmd_args)
22+
cmd = '{options} {cmd}'.format(cmd=cmd_args, options=kwargs.get('args', ''))
23+
config = Configuration(command_args=cmd)
2124

2225
result_tmp_dir = mkdtemp(dir=os.environ.get('TEST_TMP', None))
2326
stream_opener = StreamOpener(filename=result_tmp_dir)

allure-behave/features/steps/report_steps.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,3 @@ def step_impl(context, item):
8484
context_matcher = getattr(context, item)
8585
matcher = partial(context_matcher, has_attachment)
8686
assert_that(context.allure_report, matcher())
87-
88-
89-
90-
91-
92-
93-
94-
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Feature: Language
2+
Scenario: Use russian
3+
Given feature definition ru
4+
"""
5+
Функционал: Язык
6+
7+
Сценарий: На русском
8+
Допустим passed step
9+
"""
10+
When I run behave with allure formatter with options "--lang ru"
11+
Then allure report has a scenario with name "На русском"

allure-behave/src/listener.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def stop_scenario(self, scenario):
8080

8181
def start_step(self, step):
8282
self.current_step_uuid = uuid4()
83-
name = '{keyword} {title}'.format(keyword=step.keyword, title=step.name)
83+
name = u'{keyword} {title}'.format(keyword=step.keyword, title=step.name)
8484
parent_uuid = self.current_before_uuid or self.current_scenario_uuid
8585
allure_step = TestStepResult(name=name, start=now())
8686

allure-behave/src/utils.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,11 @@ def step_status(result):
7373

7474
def step_status_details(result):
7575
if result.exception:
76-
message = ','.join(map(str, result.exception.args))
77-
message = '{name}: {message}'.format(name=result.exception.__class__.__name__, message=message)
78-
trace = '\n'.join(traceback.format_tb(result.exc_traceback)) if result.exc_traceback else None
76+
message = u','.join(map(str, result.exception.args))
77+
message = u'{name}: {message}'.format(name=result.exception.__class__.__name__, message=message)
78+
trace = u'\n'.join(traceback.format_tb(result.exc_traceback)) if result.exc_traceback else None
7979
return StatusDetails(message=message, trace=trace)
8080
elif result.status == 'undefined':
81-
message = u"\nYou can implement step definitions for undefined steps with "
82-
message += u"these snippets:\n\n"
81+
message = u'\nYou can implement step definitions for undefined steps with these snippets:\n\n'
8382
message += make_undefined_step_snippet(result)
8483
return StatusDetails(message=message)

allure-behave/tox.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ envlist=
33
py{27,33,34,35}
44
static_check
55

6-
76
[testenv]
87
passenv =
98
HOME

allure-python-commons/src/model2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def _write(report_dir, item, glob):
1919
data = asdict(item, filter=lambda attr, value: not (type(value) != bool and not bool(value)))
2020
with io.open(os.path.join(report_dir, filename), 'w', encoding='utf8') as json_file:
2121
if sys.version_info.major < 3:
22-
json_file.write(unicode(json.dumps(data, indent=indent, ensure_ascii=False)))
22+
json_file.write(unicode(json.dumps(data, indent=indent, ensure_ascii=False, encoding='utf8')))
2323
else:
2424
json.dump(data, json_file, indent=indent, ensure_ascii=False)
2525

allure-python-commons/src/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
def md5(*args):
77
m = hashlib.md5()
88
for arg in args:
9-
part = str(arg).encode('utf-8')
9+
part = arg.encode('utf-8')
1010
m.update(part)
1111
return m.hexdigest()
1212

0 commit comments

Comments
 (0)