-
Notifications
You must be signed in to change notification settings - Fork 182
Better discovery of macos system version to determine proper platform tag #314
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
Changes from 5 commits
99a8bbf
a3da68d
93f1809
9144297
d4ad3d9
306cde9
be741f7
1cde26c
b1dd2c4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| import os | ||
| from wheel.lib_file_analyse import extract_macosx_min_system_version | ||
|
Czaki marked this conversation as resolved.
Outdated
|
||
| from wheel.pep425tags import get_platform | ||
|
|
||
|
|
||
| def test_read_from_dynlib(): | ||
| dirname = os.path.dirname(__file__) | ||
| dylib_dir = os.path.join(dirname, "testdata", | ||
| "macos_minimal_system_version") | ||
| versions = [ | ||
| ("test_lib_10_6_fat.dynlib", "10.6"), | ||
| ("test_lib_10_10_fat.dynlib", "10.10"), | ||
| ("test_lib_10_14_fat.dynlib", "10.14"), | ||
| ("test_lib_10_6.dynlib", "10.6"), | ||
| ("test_lib_10_10.dynlib", "10.10"), | ||
| ("test_lib_10_14.dynlib", "10.14"), | ||
| ("test_lib_10_6_386.dynlib", "10.6"), | ||
| ("test_lib_10_10_386.dynlib", "10.10"), | ||
| ("test_lib_10_14_386.dynlib", "10.14"), | ||
| ("test_lib_multiple_fat.dynlib", "10.14") | ||
| ] | ||
| for file_name, ver in versions: | ||
| extracted = extract_macosx_min_system_version( | ||
| os.path.join(dylib_dir, file_name) | ||
| ) | ||
| str_ver = str(extracted[0]) + "." + str(extracted[1]) | ||
| assert str_ver == ver | ||
| assert extract_macosx_min_system_version( | ||
| os.path.join(dylib_dir, "test_lib.c") | ||
| ) is None | ||
|
|
||
|
|
||
| def test_get_platform_macos(mocker, capsys): | ||
| print(mocker, mocker.patch, mocker.patch.mock_module) | ||
| dirname = os.path.dirname(__file__) | ||
| dylib_dir = os.path.join(dirname, "testdata", | ||
| "macos_minimal_system_version") | ||
| with mocker.patch("distutils.util.get_platform", return_value="macosx-10.14-x86_64"): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you're using mocks in
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm learning how to use mock. If I good understand in python 2.7 there is preference to use mock library and in python 3.4+ use And I do not have idea how test this functions without mock. How to fix it in best way. change dependency on
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Python 2.6 did not have
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I rewrite tests to base on |
||
| assert get_platform(dylib_dir) == "macosx_10_14_x86_64" | ||
| with mocker.patch("distutils.util.get_platform", return_value="macosx-10.9-x86_64"): | ||
| assert get_platform(dylib_dir) == "macosx_10_14_x86_64" | ||
| captured = capsys.readouterr() | ||
| assert "[WARNING] This wheel needs higher macosx version than" in captured.err | ||
| with mocker.patch("distutils.util.get_platform", return_value="macosx-10.9-x86_64"): | ||
| with mocker.patch("os.walk", return_value=[ | ||
| (dylib_dir, [], ["test_lib_10_6.dynlib", "test_lib_10_10_fat.dynlib"])]): | ||
| assert get_platform(dylib_dir) == "macosx_10_10_x86_64" | ||
| captured = capsys.readouterr() | ||
| assert "[WARNING] This wheel needs higher macosx version than" in captured.err | ||
| assert "test_lib_10_10_fat.dynlib" in captured.err | ||
|
|
||
| with mocker.patch("os.walk", return_value=[ | ||
| (dylib_dir, [], ["test_lib_10_6.dynlib", "test_lib_10_6_fat.dynlib"])]): | ||
| assert get_platform(dylib_dir) == "macosx_10_9_x86_64" | ||
| mocker.patch.dict('os.environ', {"MACOSX_DEPLOYMENT_TARGET": "10.10"}) | ||
| assert get_platform(dylib_dir) == "macosx_10_10_x86_64" | ||
| captured = capsys.readouterr() | ||
| assert captured.err == "" | ||
|
|
||
| mocker.stopall() | ||
| with mocker.patch("distutils.util.get_platform", return_value="macosx-10.9-x86_64"): | ||
| mocker.patch.dict('os.environ', {"MACOSX_DEPLOYMENT_TARGET": "10.8"}) | ||
| with mocker.patch("os.walk", return_value=[ | ||
| (dylib_dir, [], ["test_lib_10_6.dynlib", "test_lib_10_6_fat.dynlib"])]): | ||
| assert get_platform(dylib_dir) == "macosx_10_9_x86_64" | ||
| captured = capsys.readouterr() | ||
| print("aa", captured.err) | ||
| assert "[WARNING] MACOSX_DEPLOYMENT_TARGET is set to lower value" in captured.err | ||
| with mocker.patch("os.walk", return_value=[ | ||
| (dylib_dir, [], ["test_lib_10_6.dynlib", "test_lib_10_10_fat.dynlib"])]): | ||
| assert get_platform(dylib_dir) == "macosx_10_10_x86_64" | ||
| captured = capsys.readouterr() | ||
| print("aa", captured.err) | ||
| assert "[WARNING] MACOSX_DEPLOYMENT_TARGET is set to lower value" in captured.err | ||
| mocker.stopall() | ||
|
|
||
|
|
||
| def test_get_platform_linux(mocker): | ||
| with mocker.patch("distutils.util.get_platform", return_value="linux_x86_64"): | ||
| mocker.patch("sys.maxsize", new=2147483647) | ||
| assert get_platform(None) == "linux_i686" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| int num_of_letters(char* text){ | ||
| int num = 0; | ||
| char * lett = text; | ||
| while (lett != 0){ | ||
| if (*lett >= 'a' && *lett <= 'z'){ | ||
| num += 1; | ||
| } else if (*lett >= 'A' && *lett <= 'Z'){ | ||
| num += 1; | ||
| } | ||
| lett += 1; | ||
| } | ||
| return num; | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.