Skip to content

Commit d18bc65

Browse files
author
Luiko Czub
committed
fix incorrect IS_PY3 detection #114
1 parent 19c93ca commit d18bc65

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

src/testlink/testlinkapigeneric.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,17 @@
1818
# ------------------------------------------------------------------------
1919

2020
import sys, os.path
21-
IS_PY3 = sys.version_info[0] < 3
22-
if IS_PY3:
21+
IS_PY3 = sys.version_info[0] > 2
22+
if not IS_PY3:
23+
# importing required py2 modules
2324
import xmlrpclib
2425
# in py 3 encodestring is deprecated and an alias for encodebytes
2526
# see issue #39 and compare py2 py3 doc
2627
# https://docs.python.org/2/library/base64.html#base64.encodestring
2728
# https://docs.python.org/3/library/base64.html#base64.encodebytes
2829
from base64 import encodestring as encodebytes
2930
else:
31+
# importing required py3 modules
3032
import xmlrpc.client as xmlrpclib
3133
from base64 import encodebytes
3234

test/utest-offline/test_py3_vs_py2.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#! /usr/bin/python
2+
# -*- coding: UTF-8 -*-
3+
4+
# Copyright 2018 Luiko Czub, TestLink-API-Python-client developers
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
# ------------------------------------------------------------------------
19+
20+
# TestCases for Testlink API clients handling py2 and py3 differences
21+
# - TestlinkAPIClient, TestlinkAPIGeneric
22+
#
23+
24+
import pytest
25+
#from conftest import api_general_client, api_generic_client
26+
27+
def test_IS_PY3_same_state():
28+
from testlink.proxiedtransport import IS_PY3 as proxie_is_py3
29+
from testlink.testlinkapigeneric import IS_PY3 as tl_is_py3
30+
assert proxie_is_py3 == tl_is_py3
31+

0 commit comments

Comments
 (0)