Skip to content
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

Added option to manually set messages encoding for pytest plugin #100

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

capgelka
Copy link

I had a problem on teamcity agent - automatically detected encoding is cp1252 which is wrong and I got encoding error. So I added option to allow manually setting encoding.

@shalupov
Copy link
Contributor

Could you provide steps to reproduce the problem?

I've actually run your example with one modification:

# coding=utf-8
import pytest

def test_cp():
    assert 'Ф'.encode('utf8') != b'\xd0\xa4'

python 3.3 (3.5 also ok) on Windows 10 (russian oem encoding):

sys.stdout.encoding: cp866
============================= test session starts =============================
platform win32 -- Python 3.3.5, pytest-2.9.1, py-1.4.31, pluggy-0.3.1
rootdir: C:\work\teamcity-messages, inifile:
plugins: teamcity-messages-1.17
collected 1 items

encoding_test.py ##teamcity[testStarted timestamp='2016-05-21T15:16:58.413' captureStandardOutput='false' flowId='tests.guinea-pigs.pytest.encoding_test.test_c
p' name='tests.guinea-pigs.pytest.encoding_test.test_cp']
F##teamcity[testFailed timestamp='2016-05-21T15:16:58.425' details='def test_cp():|n>       assert |'Ф|'.encode(|'utf8|') != b|'\xd0\xa4|'|nE       assert b|'\
xd0\xa4|' != b|'\xd0\xa4|'|nE        +  where b|'\xd0\xa4|' = <built-in method encode of str object at 0x00000000032F3C90>(|'utf8|')|nE        +    where <buil
t-in method encode of str object at 0x00000000032F3C90> = |'Ф|'.encode|n|nencoding_test.py:5: AssertionError' flowId='tests.guinea-pigs.pytest.encoding_test.te
st_cp' message='tests\guinea-pigs\pytest\encoding_test.py:3 (test_cp)' name='tests.guinea-pigs.pytest.encoding_test.test_cp']
##teamcity[testFinished timestamp='2016-05-21T15:16:58.427' duration='0' flowId='tests.guinea-pigs.pytest.encoding_test.test_cp' name='tests.guinea-pigs.pytest
.encoding_test.test_cp']


================================== FAILURES ===================================
___________________________________ test_cp ___________________________________

    def test_cp():
>       assert 'Ф'.encode('utf8') != b'\xd0\xa4'
E       assert b'\xd0\xa4' != b'\xd0\xa4'
E        +  where b'\xd0\xa4' = <built-in method encode of str object at 0x00000000032F3C90>('utf8')
E        +    where <built-in method encode of str object at 0x00000000032F3C90> = 'Ф'.encode

encoding_test.py:5: AssertionError
========================== 1 failed in 0.03 seconds ===========================

@capgelka
Copy link
Author

Unfortunately I can't. The problem with wrong encoding was only on teamcity agent, not my local machine. If I had known what make windows to use cp1252 by default, I would have changed windows setting to solve it.

Tests from ccf6bba commit just to check if new option was applied. I added because thought it would be bad pull request with new option not covered by tests. I am sorry if it broken CI, on my local machine new tests passed.
In both new tests internal pytest test should not passed, so your example if it was for [https://github.com//pull/100/commits/ccf6bba7292f3b597875e34c8e8cae2f9222a194#diff-87d3cd8521c2572c31dc48328dfe9448R69]? not for test without manually set encoding failed as expected.
Maybe such kind of integration test with failed internal test is not good. But I still have no idea how one can better test this option.

@shalupov
Copy link
Contributor

As far as I know it's about OEM encoding (aka codepage for non unicode programs), try https://superuser.com/questions/497857/how-to-change-language-for-non-unicode-programs-in-windows-8

I'll think about the integration test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants