Skip to content

Commit e287136

Browse files
authored
remove io.open from getting version code (appium#334)
* remove io.open * remove appium module from release script
1 parent 32e46a4 commit e287136

3 files changed

Lines changed: 9 additions & 11 deletions

File tree

appium/common/helper.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
import io
1616
import os
1717

18+
from appium import version as appium_version
19+
1820

1921
def appium_bytes(value, encoding):
2022
"""
@@ -41,9 +43,4 @@ def library_version():
4143
Return a version of this python library
4244
"""
4345

44-
global_param = {}
45-
exec(
46-
io.open(os.path.join(os.path.dirname('__file__'), 'appium', 'version.py'), encoding='utf-8').read(),
47-
global_param
48-
)
49-
return global_param['version']
46+
return appium_version.version

script/release.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
import os
1717
import sys
18-
from appium.common.helper import library_version
18+
import io
1919

2020
VERSION_FILE_PATH = os.path.join(os.path.dirname('__file__'), 'appium', 'version.py')
2121
CHANGELOG_PATH = os.path.join(os.path.dirname('__file__'), 'CHANGELOG.rst')
@@ -26,7 +26,8 @@
2626

2727

2828
def get_current_version():
29-
current = library_version()
29+
current = io.open(os.path.join(os.path.dirname('__file__'), 'appium',
30+
'version.py'), encoding='utf-8').read().rstrip()
3031
print('The current version is {}, type a new one'.format(MESSAGE_YELLOW.format(current)))
3132
return current
3233

test/unit/webdriver/webdriver_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import httpretty
1717
from appium import webdriver
1818

19-
from appium.common.helper import library_version
19+
from appium import version as appium_version
2020

2121

2222
class TestWebDriverWebDriver(object):
@@ -44,7 +44,7 @@ def test_create_session(self):
4444

4545
request = httpretty.HTTPretty.latest_requests[0]
4646
assert request.headers['content-type'] == 'application/json;charset=UTF-8'
47-
assert 'appium/python {} (selenium'.format(library_version()) in request.headers['user-agent']
47+
assert 'appium/python {} (selenium'.format(appium_version.version) in request.headers['user-agent']
4848

4949
request_json = json.loads(httpretty.HTTPretty.latest_requests[0].body.decode('utf-8'))
5050
assert request_json.get('capabilities') is not None
@@ -77,7 +77,7 @@ def test_create_session_forceMjsonwp(self):
7777

7878
request = httpretty.HTTPretty.latest_requests[0]
7979
assert request.headers['content-type'] == 'application/json;charset=UTF-8'
80-
assert 'appium/python {} (selenium'.format(library_version()) in request.headers['user-agent']
80+
assert 'appium/python {} (selenium'.format(appium_version.version) in request.headers['user-agent']
8181

8282
request_json = json.loads(httpretty.HTTPretty.latest_requests[0].body.decode('utf-8'))
8383
assert request_json.get('capabilities') is None

0 commit comments

Comments
 (0)