Skip to content

Commit

Permalink
Tests: Add Darwin mark.
Browse files Browse the repository at this point in the history
  • Loading branch information
matan1008 committed Feb 27, 2022
1 parent ffaae1f commit 61448b8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/rpcclient/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import sys

import pytest

from rpcclient.client_factory import create_client
Expand All @@ -21,13 +23,16 @@ def pytest_configure(config):
'markers',
'''local_only: marks tests that require features the CI lacks (deselect with '-m "not local_only"')'''
)
config.addinivalue_line('markers', 'darwin: marks tests that require darwin platform to run')


def pytest_collection_modifyitems(config, items):
if not config.getoption('--ci'):
# --ci given in cli: skip local only tests.
return
skip_local_only = pytest.mark.skip(reason='remove --ci option to run')
skip_not_darwin = pytest.mark.skip(reason='Darwin system is required for this test')
for item in items:
if 'local_only' in item.keywords:
if 'local_only' in item.keywords and config.getoption('--ci'):
# --ci given in cli: skip local only tests.
item.add_marker(skip_local_only)
if 'darwin' in item.keywords and sys.platform != 'darwin':
# Skip test that require Darwin on non Darwin system
item.add_marker(skip_not_darwin)
11 changes: 11 additions & 0 deletions src/rpcclient/tests/test_darwin_symbol.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import pytest


@pytest.mark.darwin
def test_objc_symbol_method_by_method_name(client):
NSString = client.objc_get_class('NSString')
str1 = NSString.stringWithCString_encoding_('Taylor Swift', 1).objc_symbol
assert str1.cStringUsingEncoding_(1).peek_str() == 'Taylor Swift'
assert str1.length == len('Taylor Swift')
assert str1.lowercaseString().cStringUsingEncoding_(1).peek_str() == 'taylor swift'
assert str1.uppercaseString().cStringUsingEncoding_(1).peek_str() == 'TAYLOR SWIFT'

0 comments on commit 61448b8

Please sign in to comment.