From a6c23ffce6138bd6a7da8894ec137b6e0e6f34e6 Mon Sep 17 00:00:00 2001 From: kronenthaler Date: Wed, 11 Oct 2023 20:42:26 +0200 Subject: [PATCH] convert assertions from nosetest to pytest style --- .gitignore | 1 + tests/TestPBXGenericObject.py | 62 ++-- tests/TestPBXKey.py | 2 +- tests/TestPBXObjects.py | 56 ++-- tests/TestXCodeProject.py | 23 +- tests/pbxcli/TestPBXCLI.py | 32 ++- tests/pbxcli/TestPBXProjFile.py | 59 ++-- tests/pbxcli/TestPBXProjFlag.py | 12 +- tests/pbxcli/TestPBXProjFolder.py | 61 ++-- tests/pbxcli/TestPBXProjShow.py | 78 ++--- tests/pbxextensions/TestProjectFiles.py | 267 ++++++++--------- tests/pbxextensions/TestProjectFlags.py | 269 +++++++++--------- tests/pbxextensions/TestProjectGroups.py | 131 ++++----- tests/pbxsections/TestPBXBuildFile.py | 74 ++--- .../pbxsections/TestPBXContainerItemProxy.py | 2 +- .../pbxsections/TestPBXCopyFilesBuildPhase.py | 4 +- tests/pbxsections/TestPBXFileReference.py | 18 +- .../TestPBXFrameworksBuildPhase.py | 2 +- tests/pbxsections/TestPBXGenericBuildPhase.py | 6 +- tests/pbxsections/TestPBXGenericTarget.py | 4 +- tests/pbxsections/TestPBXGroup.py | 68 ++--- tests/pbxsections/TestPBXHeadersBuildPhase.py | 2 +- tests/pbxsections/TestPBXProject.py | 20 +- .../pbxsections/TestPBXResourcesBuildPhase.py | 2 +- .../TestPBXShellScriptBuildPhase.py | 4 +- tests/pbxsections/TestPBXSourcesBuildPhase.py | 2 +- tests/pbxsections/TestPBXTargetDependency.py | 2 +- tests/pbxsections/TestXCBuildConfiguration.py | 42 +-- tests/pbxsections/TestXCConfigurationList.py | 8 +- .../TestXCRemoteSwiftPackageReference.py | 8 +- .../TestXCSwiftPackageProductDependency.py | 4 +- 31 files changed, 669 insertions(+), 656 deletions(-) diff --git a/.gitignore b/.gitignore index 858bfbfd..e169e3d2 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ coverage.xml # Mac OS X cruft .DS_Store tests/parent_group +*.bak diff --git a/tests/TestPBXGenericObject.py b/tests/TestPBXGenericObject.py index f412922b..e2cfddb8 100644 --- a/tests/TestPBXGenericObject.py +++ b/tests/TestPBXGenericObject.py @@ -9,33 +9,33 @@ class PBXGenericObjectTest(unittest.TestCase): def testParseCreateAttributes(self): obj = {"a": "varA", "b": [1, 2, 3], "c": {"c1": "varC1"}} dobj = PBXGenericObject().parse(obj) - self.assertEqual(dobj.a, "varA") - self.assertEqual(dobj.b, [1, 2, 3]) - self.assertIsNotNone(dobj.c) + assert dobj.a == "varA" + assert dobj.b == [1, 2, 3] + assert dobj.c is not None def testParseCreateObjectOfRightTypes(self): obj = {"objects": {"id": {"isa": "type"}}} dobj = PBXGenericObject().parse(obj) - self.assertIsInstance(dobj.objects, objects) + assert isinstance(dobj.objects, objects) def testParseKey(self): obj = "FDDF6A571C68E5B100D7A645" dobj = PBXGenericObject().parse(obj) - self.assertIsInstance(dobj, PBXKey) + assert isinstance(dobj, PBXKey) def testEscapeItem(self): - self.assertEqual(PBXGenericObject._escape("/bin/sh"), "/bin/sh") - self.assertEqual(PBXGenericObject._escape("abcdefghijklmnopqrstuvwyz0123456789"), - "abcdefghijklmnopqrstuvwyz0123456789") - self.assertEqual(PBXGenericObject._escape("some spaces"), '"some spaces"') - self.assertEqual(PBXGenericObject._escape("a.valid_id."), "a.valid_id.") - self.assertEqual(PBXGenericObject._escape("a-invalid-id"), '"a-invalid-id"') - self.assertEqual(PBXGenericObject._escape(""), '""') - self.assertEqual(PBXGenericObject._escape("script \\ continuation"), '"script \\\\ continuation"') - self.assertEqual(PBXGenericObject._escape("/bin/sh find .. -name '*.framework'", exclude=["\'"]), - "\"/bin/sh find .. -name '*.framework'\"") + assert PBXGenericObject._escape("/bin/sh") == "/bin/sh" + assert PBXGenericObject._escape("abcdefghijklmnopqrstuvwyz0123456789") == \ + "abcdefghijklmnopqrstuvwyz0123456789" + assert PBXGenericObject._escape("some spaces") == '"some spaces"' + assert PBXGenericObject._escape("a.valid_id.") == "a.valid_id." + assert PBXGenericObject._escape("a-invalid-id") == '"a-invalid-id"' + assert PBXGenericObject._escape("") == '""' + assert PBXGenericObject._escape("script \\ continuation") == '"script \\\\ continuation"' + assert PBXGenericObject._escape("/bin/sh find .. -name '*.framework'", exclude=["\'"]) == \ + "\"/bin/sh find .. -name '*.framework'\"" def testPrintObject(self): obj = {"a": "varA", "b": [1, 2, 3], "c": {"c1": "FDDF6A571C68E5B100D7A645"}} @@ -43,64 +43,64 @@ def testPrintObject(self): expected = '{\n\ta = varA;\n\tb = (\n\t\t1,\n\t\t2,\n\t\t3,\n\t);\n\tc = {\n\t\tc1 = FDDF6A571C68E5B100D7A645;\n\t};\n}' - self.assertEqual(dobj.__repr__(), expected) + assert dobj.__repr__() == expected def testGetItem(self): obj = {"a": "varA", "b": [1, 2, 3], "c": {"c1": "FDDF6A571C68E5B100D7A645"}} dobj = PBXGenericObject().parse(obj) - self.assertIsInstance(dobj["c"]["c1"], PBXKey) - self.assertIsNone(dobj['X']) + assert isinstance(dobj["c"]["c1"], PBXKey) + assert dobj['X'] is None def testSetItemNone(self): obj = {} dobj = PBXGenericObject().parse(obj) - self.assertIsNone(dobj['something']) + assert dobj['something'] is None dobj['something'] = None - self.assertIsNone(dobj['something']) + assert dobj['something'] is None def testSetItemString(self): obj = {} dobj = PBXGenericObject().parse(obj) - self.assertIsNone(dobj['something']) + assert dobj['something'] is None dobj['something'] = 'yes' - self.assertEqual(dobj['something'], 'yes') + assert dobj['something'] == 'yes' def testSetItemListOfZero(self): obj = {} dobj = PBXGenericObject().parse(obj) - self.assertIsNone(dobj['something']) + assert dobj['something'] is None dobj['something'] = [] - self.assertIsNone(dobj['something']) + assert dobj['something'] is None def testSetItemListOfOne(self): obj = {} dobj = PBXGenericObject().parse(obj) - self.assertIsNone(dobj['something']) + assert dobj['something'] is None dobj['something'] = ['yes'] - self.assertEqual(dobj['something'], 'yes') + assert dobj['something'] == 'yes' def testSetItemListOfTwo(self): obj = {} dobj = PBXGenericObject().parse(obj) - self.assertIsNone(dobj['something']) + assert dobj['something'] is None dobj['something'] = ['yes', 'yes'] - self.assertEqual(dobj['something'], ['yes', 'yes']) + assert dobj['something'] == ['yes', 'yes'] def testResolveComment(self): obj = {"a": {"name": "A"}, "b": {"path": "B"}, "c": {"c1": "FDDF6A571C68E5B100D7A645"}} dobj = PBXGenericObject().parse(obj) - self.assertEqual(dobj._resolve_comment('a'), 'A') - self.assertEqual(dobj._resolve_comment('b'), 'B') - self.assertEqual(dobj._resolve_comment('c'), None) + assert dobj._resolve_comment('a') == 'A' + assert dobj._resolve_comment('b') == 'B' + assert dobj._resolve_comment('c') == None diff --git a/tests/TestPBXKey.py b/tests/TestPBXKey.py index a48a11ec..f4e02e6e 100644 --- a/tests/TestPBXKey.py +++ b/tests/TestPBXKey.py @@ -8,4 +8,4 @@ def testGetComment(self): key = PBXKey("123", None) key._get_comment = lambda: "comment" - self.assertEqual(key.__repr__(), "123 /* comment */") + assert key.__repr__() == "123 /* comment */" diff --git a/tests/TestPBXObjects.py b/tests/TestPBXObjects.py index 969bf566..ab2a1da0 100644 --- a/tests/TestPBXObjects.py +++ b/tests/TestPBXObjects.py @@ -10,47 +10,47 @@ def testParseNonObject(self): obj = [1, 2, 3] dobj = objects().parse(obj) - self.assertIsInstance(dobj, list) + assert isinstance(dobj, list) def testGetKeys(self): dobj = objects().parse(PBXObjectTest.MINIMUM_OBJ) keys = dobj.get_keys() - self.assertListEqual(keys, ['1', '2', '3']) + assert keys == ['1', '2', '3'] def testParseGroupsPhases(self): dobj = objects().parse(PBXObjectTest.MINIMUM_OBJ) - self.assertEqual(dobj._sections.__len__(), 2) - self.assertEqual(dobj._sections['phase1'].__len__(), 2) - self.assertEqual(dobj._sections['phase2'].__len__(), 1) + assert dobj._sections.__len__() == 2 + assert dobj._sections['phase1'].__len__() == 2 + assert dobj._sections['phase2'].__len__() == 1 def testPrintSeparateSections(self): dobj = objects().parse(PBXObjectTest.MINIMUM_OBJ) string = dobj.__repr__() - self.assertTrue(string.__contains__('/* Begin phase1 section */')) - self.assertTrue(string.__contains__('/* End phase1 section */')) - self.assertTrue(string.__contains__('/* Begin phase2 section */')) - self.assertTrue(string.__contains__('/* End phase2 section */')) + assert string.__contains__('/* Begin phase1 section */') + assert string.__contains__('/* End phase1 section */') + assert string.__contains__('/* Begin phase2 section */') + assert string.__contains__('/* End phase2 section */') def testGetItem(self): dobj = objects().parse(PBXObjectTest.MINIMUM_OBJ) - self.assertIsNotNone(dobj['1']) - self.assertIsNone(dobj['4']) + assert dobj['1'] is not None + assert dobj['4'] is None def testContains(self): dobj = objects().parse(PBXObjectTest.MINIMUM_OBJ) - self.assertTrue('1' in dobj) - self.assertFalse('4' in dobj) + assert '1' in dobj + assert not ('4' in dobj) def testGetObjectsInsection(self): dobj = objects().parse(PBXObjectTest.MINIMUM_OBJ) sections = dobj.get_objects_in_section('phase1', 'phase2') - self.assertSetEqual(set(sections).intersection(dobj._sections['phase1']), set(dobj._sections['phase1'])) - self.assertSetEqual(set(sections).intersection(dobj._sections['phase2']), set(dobj._sections['phase2'])) - self.assertEqual(dobj.get_objects_in_section('phaseX'), []) + assert set(sections).intersection(dobj._sections['phase1']) == set(dobj._sections['phase1']) + assert set(sections).intersection(dobj._sections['phase2']) == set(dobj._sections['phase2']) + assert dobj.get_objects_in_section('phaseX') == [] def testGetTargets(self): obj = { @@ -60,11 +60,11 @@ def testGetTargets(self): } dobj = objects().parse(obj) - self.assertEqual(dobj.get_targets().__len__(), 3) - self.assertEqual(dobj.get_targets('app').__len__(), 1) - self.assertEqual(dobj.get_targets('report').__len__(), 1) - self.assertEqual(dobj.get_targets('whatever').__len__(), 0) - self.assertEqual(dobj.get_targets(['app', 'something']).__len__(), 2) + assert dobj.get_targets().__len__() == 3 + assert dobj.get_targets('app').__len__() == 1 + assert dobj.get_targets('report').__len__() == 1 + assert dobj.get_targets('whatever').__len__() == 0 + assert dobj.get_targets(['app', 'something']).__len__() == 2 def testGetConfigurationTargets(self): obj = { @@ -80,16 +80,16 @@ def testGetConfigurationTargets(self): dobj = objects().parse(obj) result = [x for x in dobj.get_configurations_on_targets()] - self.assertEqual(result.__len__(), 4) - self.assertSetEqual({x.id for x in result}, {'5', '6', '7', '8'}) + assert result.__len__() == 4 + assert {x.id for x in result} == {'5', '6', '7', '8'} result = [x for x in dobj.get_configurations_on_targets(target_name='app')] - self.assertEqual(result.__len__(), 2) - self.assertSetEqual({x.id for x in result}, {'5', '6'}) + assert result.__len__() == 2 + assert {x.id for x in result} == {'5', '6'} result = [x for x in dobj.get_configurations_on_targets(configuration_name='Release')] - self.assertSetEqual({x.id for x in result}, {'5', '7'}) + assert {x.id for x in result} == {'5', '7'} result = [x for x in dobj.get_configurations_on_targets(target_name='app', configuration_name='Release')] - self.assertEqual(result.__len__(), 1) - self.assertSetEqual({x.id for x in result}, {'5'}) + assert result.__len__() == 1 + assert {x.id for x in result} == {'5'} diff --git a/tests/TestXCodeProject.py b/tests/TestXCodeProject.py index 0f7fda27..08effc4b 100644 --- a/tests/TestXCodeProject.py +++ b/tests/TestXCodeProject.py @@ -3,6 +3,7 @@ import unittest from pbxproj import XcodeProject +import re class XCodeProjectTest(unittest.TestCase): @@ -47,62 +48,62 @@ def tearDown(self): def testSaveOnGivenPath(self): XcodeProject().save("results/sample") - self.assertTrue(os.path.exists("results/sample")) + assert os.path.exists("results/sample") def testSaveOnDefaultPath(self): XcodeProject({}, "results/default").save() - self.assertTrue(os.path.exists("results/default")) + assert os.path.exists("results/default") def testBackup(self): project = XcodeProject({}, 'results/default') project.save('results/default') backup_name = project.backup() - self.assertRegex(backup_name, r'_[0-9]{6}-[0-9]{6}\.backup') + assert re.search(r'_[0-9]{6}-[0-9]{6}\.backup', backup_name) def testGetIds(self): project = XcodeProject({'objects':{'1':{'isa':'a'}, '2':{'isa':'a'}}}) - self.assertListEqual(project.get_ids(), ['1', '2']) + assert project.get_ids() == ['1', '2'] def testGetBuildFilesForFile(self): project = XcodeProject(self.obj) build_files = project.get_build_files_for_file('file1') - self.assertListEqual(build_files, [project.objects['build_file1']]) + assert build_files == [project.objects['build_file1']] def testGetTargetByNameExisting(self): project = XcodeProject(self.obj) target = project.get_target_by_name('app') - self.assertEqual(target, project.objects['1']) + assert target == project.objects['1'] def testGetTargetByNameNonExisting(self): project = XcodeProject(self.obj) target = project.get_target_by_name('non-existing') - self.assertIsNone(target) + assert target is None def testGetBuildPhasesByName(self): project = XcodeProject(self.obj) build_phases = project.get_build_phases_by_name('PBXGenericBuildPhase') - self.assertEqual(build_phases.__len__(), 2) + assert build_phases.__len__() == 2 def testGetBuildConfigurationsByTarget(self): project = XcodeProject(self.obj) build_configurations = project.get_build_configurations_by_target( 'app') - self.assertListEqual(build_configurations, ['Release', 'Debug']) + assert build_configurations == ['Release', 'Debug'] def testGetBuildConfigurationsByTargetNotExistent(self): project = XcodeProject(self.obj) build_configurations = project.get_build_configurations_by_target( 'appThatDoesNotExists') - self.assertIsNone(build_configurations) + assert build_configurations is None def testConsistency(self): with open('samplescli/massive.pbxproj', 'r') as file: @@ -110,5 +111,5 @@ def testConsistency(self): project = XcodeProject.load('samplescli/massive.pbxproj') saved = project.__repr__() + '\n' - self.assertEqual(saved, original) + assert saved == original diff --git a/tests/pbxcli/TestPBXCLI.py b/tests/pbxcli/TestPBXCLI.py index d20699f3..24498a93 100644 --- a/tests/pbxcli/TestPBXCLI.py +++ b/tests/pbxcli/TestPBXCLI.py @@ -6,7 +6,9 @@ from pbxproj import XcodeProject from pbxproj.pbxcli import open_project, resolve_backup, backup_project, command_parser, PROJECT_PLACEHOLDER -from tests.pbxcli import BASE_PROJECT_PATH +import pytest + +BASE_PROJECT_PATH = 'samplescli/project.pbxproj' class PBXCLITest(unittest.TestCase): @@ -17,29 +19,29 @@ def tearDown(self): def testOpenProjectWithFullPath(self): project = open_project({PROJECT_PLACEHOLDER: BASE_PROJECT_PATH}) - self.assertIsNotNone(project) + assert project is not None def testOpenProjectWithDirectory(self): project = open_project({PROJECT_PLACEHOLDER: 'samplescli'}) - self.assertIsNotNone(project) + assert project is not None def testLoadingPlistFormat(self): project = open_project({PROJECT_PLACEHOLDER: 'samplescli/plist.pbxproj'}) - self.assertIsNotNone(project) + assert project is not None def testOpenProjectInvalidPath(self): - with self.assertRaisesRegex(Exception, '^Project file not found'): + with pytest.raises(Exception, match='^Project file not found'): open_project({PROJECT_PLACEHOLDER: 'whatever'}) def testBackupNoFlag(self): project = XcodeProject({}, path=BASE_PROJECT_PATH) self.backup_file = backup_project(project, {'--backup': False}) - self.assertIsNone(self.backup_file) + assert self.backup_file is None def testBackupWithFlag(self): project = XcodeProject({}, path=BASE_PROJECT_PATH) self.backup_file = backup_project(project, {'--backup': True}) - self.assertIsNotNone(self.backup_file) + assert self.backup_file is not None def testResolveBackupWithoutFlag(self): project = XcodeProject({}, path=BASE_PROJECT_PATH) @@ -48,7 +50,7 @@ def testResolveBackupWithoutFlag(self): resolve_backup(project, tmpfile.name, {'--backup': False}) - self.assertTrue(os.path.exists(tmpfile.name)) + assert os.path.exists(tmpfile.name) def testResolveBackupWithFlag(self): project = XcodeProject({}, path=BASE_PROJECT_PATH) @@ -57,26 +59,26 @@ def testResolveBackupWithFlag(self): resolve_backup(project, tmpfile.name, {'--backup': True}) - self.assertFalse(os.path.exists(tmpfile.name)) + assert not os.path.exists(tmpfile.name) def testCommandWithSuccess(self): function = lambda p, a: u'test' parser = command_parser(function) sys.stdout = StringIO() parser({PROJECT_PLACEHOLDER: BASE_PROJECT_PATH, u'--backup': False}) - self.assertEqual(sys.stdout.getvalue().strip(), u'test') + assert sys.stdout.getvalue().strip() == u'test' def testCommandWithFailure(self): function = lambda p, a: u'test' parser = command_parser(function) sys.stdout = StringIO() - with self.assertRaisesRegex(SystemExit, '^1'): + with pytest.raises(SystemExit, match='^1'): parser({PROJECT_PLACEHOLDER: u'whatever/project.pbxproj', u'--backup': False}) - self.assertEqual(sys.stdout.getvalue().strip(), u'Project file not found') + assert sys.stdout.getvalue().strip() == u'Project file not found' def testOpenFileWithBrokenReferences(self): sys.stderr = StringIO() _ = open_project({PROJECT_PLACEHOLDER: 'samplescli/broken-references.pbxproj'}) - self.assertEqual(sys.stderr.getvalue().strip(), '[WARNING] The project contains missing/broken references that ' - 'may cause other problems. Open your project in Xcode and ' - 'resolve all red-colored files.') + assert sys.stderr.getvalue().strip() == '[WARNING] The project contains missing/broken references that ' \ + 'may cause other problems. Open your project in Xcode and ' \ + 'resolve all red-colored files.' diff --git a/tests/pbxcli/TestPBXProjFile.py b/tests/pbxcli/TestPBXProjFile.py index 1fcb53ae..cd579273 100644 --- a/tests/pbxcli/TestPBXProjFile.py +++ b/tests/pbxcli/TestPBXProjFile.py @@ -6,7 +6,10 @@ import pbxproj.pbxcli.pbxproj_file as pbxproj_file from pbxproj import PBXGenericObject from pbxproj.pbxcli import open_project, PROJECT_PLACEHOLDER, PATH_PLACEHOLDER -from tests.pbxcli import BASE_PROJECT_PATH, SAMPLE_PROJECT_PATH +import pytest + +SAMPLE_PROJECT_PATH = 'samplescli/test.pbxproj' +BASE_PROJECT_PATH = 'samplescli/project.pbxproj' class PBXProjFileTest(unittest.TestCase): @@ -28,7 +31,7 @@ def testRemoveFileUnknown(self): } project = open_project(args) - with self.assertRaisesRegex(Exception, '^An error occurred removing one of the files.'): + with pytest.raises(Exception, match='^An error occurred removing one of the files.'): pbxproj_file.execute(project, args) def testRemoveFileKnown(self): @@ -42,13 +45,13 @@ def testRemoveFileKnown(self): project = open_project(args) - self.assertIsNotNone(project.get_files_by_path(args[PATH_PLACEHOLDER], tree=args['--tree'])) - self.assertGreater(project.get_files_by_path(args[PATH_PLACEHOLDER], tree=args['--tree']).__len__(), 0) + assert project.get_files_by_path(args[PATH_PLACEHOLDER], tree=args['--tree']) is not None + assert project.get_files_by_path(args[PATH_PLACEHOLDER], tree=args['--tree']).__len__() > 0 result = pbxproj_file.execute(project, args) - self.assertEqual(result, 'File removed from the project.') + assert result == 'File removed from the project.' - self.assertListEqual(project.get_files_by_path(args[PATH_PLACEHOLDER], tree=args['--tree']), []) + assert project.get_files_by_path(args[PATH_PLACEHOLDER], tree=args['--tree']) == [] def testAddFilesNoResult(self): args = { @@ -66,11 +69,11 @@ def testAddFilesNoResult(self): } project = open_project(args) - self.assertListEqual(project.get_files_by_path(args[PATH_PLACEHOLDER]), []) + assert project.get_files_by_path(args[PATH_PLACEHOLDER]) == [] result = pbxproj_file.execute(project, args) - self.assertGreater(project.get_files_by_path(args[PATH_PLACEHOLDER]).__len__(), 0) - self.assertEqual(result, 'File added to the project, no build file sections created.') + assert project.get_files_by_path(args[PATH_PLACEHOLDER]).__len__() > 0 + assert result == 'File added to the project, no build file sections created.' def testAddFilesError(self): args = { @@ -88,11 +91,11 @@ def testAddFilesError(self): } project = open_project(args) - self.assertListEqual(project.get_files_by_path(args[PATH_PLACEHOLDER]), []) - with self.assertRaisesRegex(Exception, '^No files were added to the project.'): + assert project.get_files_by_path(args[PATH_PLACEHOLDER]) == [] + with pytest.raises(Exception, match='^No files were added to the project.'): pbxproj_file.execute(project, args) - self.assertEqual(project.get_files_by_path(args[PATH_PLACEHOLDER]).__len__(), 0) + assert project.get_files_by_path(args[PATH_PLACEHOLDER]).__len__() == 0 def testAddFilesSuccess(self): args = { @@ -110,11 +113,11 @@ def testAddFilesSuccess(self): } project = open_project(args) - self.assertListEqual(project.get_files_by_path(args[PATH_PLACEHOLDER]), []) + assert project.get_files_by_path(args[PATH_PLACEHOLDER]) == [] result = pbxproj_file.execute(project, args) - self.assertGreater(project.get_files_by_path(args[PATH_PLACEHOLDER]).__len__(), 0) - self.assertEqual(result, 'File added to the project.\n3 PBXBuildFile sections created.') + assert project.get_files_by_path(args[PATH_PLACEHOLDER]).__len__() > 0 + assert result == 'File added to the project.\n3 PBXBuildFile sections created.' def testAddFilesWithParentNoResult(self): args = { @@ -132,11 +135,11 @@ def testAddFilesWithParentNoResult(self): } project = open_project(args) - self.assertListEqual(project.get_files_by_path(args[PATH_PLACEHOLDER]), []) + assert project.get_files_by_path(args[PATH_PLACEHOLDER]) == [] result = pbxproj_file.execute(project, args) - self.assertGreater(project.get_files_by_path(args[PATH_PLACEHOLDER]).__len__(), 0) - self.assertEqual(result, 'File added to the project, no build file sections created.') + assert project.get_files_by_path(args[PATH_PLACEHOLDER]).__len__() > 0 + assert result == 'File added to the project, no build file sections created.' def testAddFilesWithParentError(self): @@ -155,11 +158,11 @@ def testAddFilesWithParentError(self): } project = open_project(args) - self.assertListEqual(project.get_files_by_path(args[PATH_PLACEHOLDER]), []) - with self.assertRaisesRegex(Exception, '^No files were added to the project.'): + assert project.get_files_by_path(args[PATH_PLACEHOLDER]) == [] + with pytest.raises(Exception, match='^No files were added to the project.'): pbxproj_file.execute(project, args) - self.assertEqual(project.get_files_by_path(args[PATH_PLACEHOLDER]).__len__(), 0) + assert project.get_files_by_path(args[PATH_PLACEHOLDER]).__len__() == 0 def testAddFilesWithParentSuccess(self): @@ -178,11 +181,11 @@ def testAddFilesWithParentSuccess(self): } project = open_project(args) - self.assertListEqual(project.get_files_by_path(args[PATH_PLACEHOLDER]), []) + assert project.get_files_by_path(args[PATH_PLACEHOLDER]) == [] result = pbxproj_file.execute(project, args) - self.assertGreater(project.get_files_by_path(args[PATH_PLACEHOLDER]).__len__(), 0) - self.assertEqual(result, 'File added to the project.\n3 PBXBuildFile sections created.') + assert project.get_files_by_path(args[PATH_PLACEHOLDER]).__len__() > 0 + assert result == 'File added to the project.\n3 PBXBuildFile sections created.' def testAddFilesWithHeadersScope(self): args = { @@ -201,11 +204,11 @@ def testAddFilesWithHeadersScope(self): } project = open_project(args) - self.assertListEqual(project.get_files_by_path(args[PATH_PLACEHOLDER]), []) + assert project.get_files_by_path(args[PATH_PLACEHOLDER]) == [] result = pbxproj_file.execute(project, args) - self.assertGreater(project.get_files_by_path(args[PATH_PLACEHOLDER]).__len__(), 0) - self.assertEqual(result, 'File added to the project.\n3 PBXBuildFile sections created.') + assert project.get_files_by_path(args[PATH_PLACEHOLDER]).__len__() > 0 + assert result == 'File added to the project.\n3 PBXBuildFile sections created.' file = project.get_files_by_name('fileB.h') build_file = project.get_build_files_for_file(file[0].get_id()) - self.assertEqual(build_file[0].settings.__repr__(), PBXGenericObject().parse({"ATTRIBUTES": ['Public']}).__repr__()) + assert build_file[0].settings.__repr__() == PBXGenericObject().parse({"ATTRIBUTES": ['Public']}).__repr__() diff --git a/tests/pbxcli/TestPBXProjFlag.py b/tests/pbxcli/TestPBXProjFlag.py index 743e75bd..7e80f416 100644 --- a/tests/pbxcli/TestPBXProjFlag.py +++ b/tests/pbxcli/TestPBXProjFlag.py @@ -30,14 +30,14 @@ def testAddFlags(self): project = open_project(args) for configuration in project.objects.get_configurations_on_targets(args['--target'], args['--configuration']): - self.assertTrue('MYFLAG' not in configuration.buildSettings) + assert 'MYFLAG' not in configuration.buildSettings result = pbxproj_flag.execute(project, args) - self.assertEqual(result, 'Flags added successfully.') + assert result == 'Flags added successfully.' for configuration in project.objects.get_configurations_on_targets(args['--target'], args['--configuration']): - self.assertTrue('MYFLAG' in configuration.buildSettings) - self.assertListEqual(configuration.buildSettings['MYFLAG'], ['-ObjC', '-all']) + assert 'MYFLAG' in configuration.buildSettings + assert configuration.buildSettings['MYFLAG'] == ['-ObjC', '-all'] def testRemoveFlags(self): args = { @@ -53,7 +53,7 @@ def testRemoveFlags(self): project.add_flags('MYFLAG', ['-ObjC', '-all']) result = pbxproj_flag.execute(project, args) - self.assertEqual(result, 'Flags removed successfully.') + assert result == 'Flags removed successfully.' for configuration in project.objects.get_configurations_on_targets(args['--target'], args['--configuration']): - self.assertTrue('MYFLAG' not in configuration.buildSettings) \ No newline at end of file + assert 'MYFLAG' not in configuration.buildSettings \ No newline at end of file diff --git a/tests/pbxcli/TestPBXProjFolder.py b/tests/pbxcli/TestPBXProjFolder.py index 9e99cf2b..f16c111f 100644 --- a/tests/pbxcli/TestPBXProjFolder.py +++ b/tests/pbxcli/TestPBXProjFolder.py @@ -7,7 +7,10 @@ from pbxproj import PBXGenericObject from pbxproj.pbxcli import open_project, PROJECT_PLACEHOLDER, PATH_PLACEHOLDER from pbxproj.pbxextensions.ProjectFiles import TreeType -from tests.pbxcli import BASE_PROJECT_PATH, SAMPLE_PROJECT_PATH +import pytest + +SAMPLE_PROJECT_PATH = 'samplescli/test.pbxproj' +BASE_PROJECT_PATH = 'samplescli/project.pbxproj' class PBXProjFolderTest(unittest.TestCase): @@ -29,7 +32,7 @@ def testRemoveFolderUnknown(self): } project = open_project(args) - with self.assertRaisesRegex(Exception, '^An error occurred removing one of the files.'): + with pytest.raises(Exception, match='^An error occurred removing one of the files.'): pbxproj_folder.execute(project, args) def testRemoveFolderKnown(self): @@ -43,13 +46,13 @@ def testRemoveFolderKnown(self): project = open_project(args) - self.assertIsNotNone(project.get_files_by_path(args[PATH_PLACEHOLDER], tree=args['--tree'])) - self.assertGreater(project.get_files_by_path(args[PATH_PLACEHOLDER], tree=args['--tree']).__len__(), 0) + assert project.get_files_by_path(args[PATH_PLACEHOLDER], tree=args['--tree']) is not None + assert project.get_files_by_path(args[PATH_PLACEHOLDER], tree=args['--tree']).__len__() > 0 result = pbxproj_folder.execute(project, args) - self.assertEqual(result, 'Folder removed from the project.') + assert result == 'Folder removed from the project.' - self.assertListEqual(project.get_files_by_path(args[PATH_PLACEHOLDER], tree=args['--tree']), []) + assert project.get_files_by_path(args[PATH_PLACEHOLDER], tree=args['--tree']) == [] def testAddFolderNoResult(self): args = { @@ -69,11 +72,11 @@ def testAddFolderNoResult(self): } project = open_project(args) - self.assertListEqual(project.get_files_by_path(args[PATH_PLACEHOLDER], tree=TreeType.GROUP), []) + assert project.get_files_by_path(args[PATH_PLACEHOLDER], tree=TreeType.GROUP) == [] result = pbxproj_folder.execute(project, args) - self.assertGreater(project.get_files_by_path(args[PATH_PLACEHOLDER], tree=TreeType.GROUP).__len__(), 0) - self.assertEqual(result, 'Folder added to the project, no build file sections created.') + assert project.get_files_by_path(args[PATH_PLACEHOLDER], tree=TreeType.GROUP).__len__() > 0 + assert result == 'Folder added to the project, no build file sections created.' def testAddFolderError(self): args = { @@ -93,11 +96,11 @@ def testAddFolderError(self): } project = open_project(args) - self.assertListEqual(project.get_files_by_path(args[PATH_PLACEHOLDER], tree=TreeType.GROUP), []) - with self.assertRaisesRegex(Exception, '^No files were added to the project.'): + assert project.get_files_by_path(args[PATH_PLACEHOLDER], tree=TreeType.GROUP) == [] + with pytest.raises(Exception, match='^No files were added to the project.'): pbxproj_folder.execute(project, args) - self.assertEqual(project.get_files_by_path(args[PATH_PLACEHOLDER], tree=TreeType.GROUP).__len__(), 0) + assert project.get_files_by_path(args[PATH_PLACEHOLDER], tree=TreeType.GROUP).__len__() == 0 def testAddFolderSuccess(self): args = { @@ -117,13 +120,13 @@ def testAddFolderSuccess(self): } project = open_project(args) - self.assertListEqual(project.get_files_by_path(args[PATH_PLACEHOLDER]+'/path with spaces/testLibrary.a', - tree=TreeType.GROUP), []) + assert project.get_files_by_path(args[PATH_PLACEHOLDER]+'/path with spaces/testLibrary.a', + tree=TreeType.GROUP) == [] result = pbxproj_folder.execute(project, args) - self.assertEqual(project.get_files_by_path(args[PATH_PLACEHOLDER]+'/path with spaces/testLibrary.a', - tree=TreeType.GROUP).__len__(), 0) - self.assertEqual(result, 'Folder added to the project.\n6 PBXBuildFile sections created.') + assert project.get_files_by_path(args[PATH_PLACEHOLDER]+'/path with spaces/testLibrary.a', + tree=TreeType.GROUP).__len__() == 0 + assert result == 'Folder added to the project.\n6 PBXBuildFile sections created.' def testAddFolderSuccessRecursive(self): args = { @@ -143,13 +146,13 @@ def testAddFolderSuccessRecursive(self): } project = open_project(args) - self.assertListEqual(project.get_files_by_path(args[PATH_PLACEHOLDER]+'/path with spaces/testLibrary.a', - tree=TreeType.GROUP), []) + assert project.get_files_by_path(args[PATH_PLACEHOLDER]+'/path with spaces/testLibrary.a', + tree=TreeType.GROUP) == [] result = pbxproj_folder.execute(project, args) - self.assertGreater(project.get_files_by_path(args[PATH_PLACEHOLDER]+'/path with spaces/testLibrary.a', - tree=TreeType.GROUP).__len__(), 0) - self.assertEqual(result, 'Folder added to the project.\n18 PBXBuildFile sections created.') + assert project.get_files_by_path(args[PATH_PLACEHOLDER]+'/path with spaces/testLibrary.a', + tree=TreeType.GROUP).__len__() > 0 + assert result == 'Folder added to the project.\n18 PBXBuildFile sections created.' def testAddFolderSuccessWithPublicHeaders(self): args = { @@ -170,14 +173,14 @@ def testAddFolderSuccessWithPublicHeaders(self): } project = open_project(args) - self.assertListEqual(project.get_files_by_path(args[PATH_PLACEHOLDER]+'/path with spaces/testLibrary.a', - tree=TreeType.GROUP), []) + assert project.get_files_by_path(args[PATH_PLACEHOLDER]+'/path with spaces/testLibrary.a', + tree=TreeType.GROUP) == [] result = pbxproj_folder.execute(project, args) - self.assertGreater(project.get_files_by_path(args[PATH_PLACEHOLDER]+'/path with spaces/testLibrary.a', - tree=TreeType.GROUP).__len__(), 0) - self.assertEqual(result, 'Folder added to the project.\n18 PBXBuildFile sections created.') + assert project.get_files_by_path(args[PATH_PLACEHOLDER]+'/path with spaces/testLibrary.a', + tree=TreeType.GROUP).__len__() > 0 + assert result == 'Folder added to the project.\n18 PBXBuildFile sections created.' file = project.get_files_by_name('fileB.h') build_file = project.get_build_files_for_file(file[0].get_id()) - self.assertEqual(build_file[0].settings.__repr__(), - PBXGenericObject().parse({"ATTRIBUTES": ['Public']}).__repr__()) + assert build_file[0].settings.__repr__() == \ + PBXGenericObject().parse({"ATTRIBUTES": ['Public']}).__repr__() diff --git a/tests/pbxcli/TestPBXProjShow.py b/tests/pbxcli/TestPBXProjShow.py index 3a211d3c..b6c6cdf1 100644 --- a/tests/pbxcli/TestPBXProjShow.py +++ b/tests/pbxcli/TestPBXProjShow.py @@ -25,15 +25,15 @@ def testShowAllTargetsInfo(self): project = open_project(args) result = pbxproj_show.execute(project, args) - self.assertIn('testUITests:', result) - self.assertIn('Product name: testUITests', result) - self.assertIn('Configurations: Debug, Release', result) - self.assertIn('Sources (PBXSourcesBuildPhase) file count: 1', result) + assert 'testUITests:' in result + assert 'Product name: testUITests' in result + assert 'Configurations: Debug, Release' in result + assert 'Sources (PBXSourcesBuildPhase) file count: 1' in result - self.assertIn('test:', result) - self.assertIn('Product name: test\n', result) - self.assertIn('Configurations: Debug, Release', result) - self.assertIn('Sources (PBXSourcesBuildPhase) file count: 2', result) + assert 'test:' in result + assert 'Product name: test\n' in result + assert 'Configurations: Debug, Release' in result + assert 'Sources (PBXSourcesBuildPhase) file count: 2' in result def testShowTargetBasicInfo(self): args = { @@ -49,11 +49,11 @@ def testShowTargetBasicInfo(self): project = open_project(args) result = pbxproj_show.execute(project, args) - self.assertNotIn('testUITests:', result) - self.assertNotIn('Product name: testUITests', result) + assert 'testUITests:' not in result + assert 'Product name: testUITests' not in result - self.assertIn('test:', result) - self.assertIn('Product name: test\n', result) + assert 'test:' in result + assert 'Product name: test\n' in result def testShowTargetConfigurations(self): args = { @@ -69,9 +69,9 @@ def testShowTargetConfigurations(self): project = open_project(args) result = pbxproj_show.execute(project, args) - self.assertIn('test:', result) - self.assertIn('Product name: test\n', result) - self.assertIn('Configurations: Debug, Release\n', result) + assert 'test:' in result + assert 'Product name: test\n' in result + assert 'Configurations: Debug, Release\n' in result def testShowTargetSources(self): args = { @@ -87,11 +87,11 @@ def testShowTargetSources(self): project = open_project(args) result = pbxproj_show.execute(project, args) - self.assertIn('test:', result) - self.assertIn('Product name: test\n', result) - self.assertIn('Sources:', result) - self.assertIn('AppDelegate.swift', result) - self.assertIn('VīęwČøntröłler.swift', result) + assert 'test:' in result + assert 'Product name: test\n' in result + assert 'Sources:' in result + assert 'AppDelegate.swift' in result + assert 'VīęwČøntröłler.swift' in result def testShowTargetResources(self): args = { @@ -107,12 +107,12 @@ def testShowTargetResources(self): project = open_project(args) result = pbxproj_show.execute(project, args) - self.assertIn('test:', result) - self.assertIn('Product name: test\n', result) - self.assertIn('Resources:', result) - self.assertIn('Assets.xcassets', result) - self.assertIn('LaunchScreen.storyboard', result) - self.assertIn('Main.storyboard', result) + assert 'test:' in result + assert 'Product name: test\n' in result + assert 'Resources:' in result + assert 'Assets.xcassets' in result + assert 'LaunchScreen.storyboard' in result + assert 'Main.storyboard' in result def testShowTargetHeaders(self): args = { @@ -128,11 +128,11 @@ def testShowTargetHeaders(self): project = open_project(args) result = pbxproj_show.execute(project, args) - self.assertIn('helloworld:', result) - self.assertIn('Product name: helloworld\n', result) - self.assertIn('Headers:', result) - self.assertIn('doit.h', result) - self.assertIn('helloworld.h', result) + assert 'helloworld:' in result + assert 'Product name: helloworld\n' in result + assert 'Headers:' in result + assert 'doit.h' in result + assert 'helloworld.h' in result def testShowTargetFrameworks(self): args = { @@ -148,10 +148,10 @@ def testShowTargetFrameworks(self): project = open_project(args) result = pbxproj_show.execute(project, args) - self.assertIn('helloworld:', result) - self.assertIn('Product name: helloworld\n', result) - self.assertIn('Frameworks:', result) - self.assertIn('AppKit.framework', result) + assert 'helloworld:' in result + assert 'Product name: helloworld\n' in result + assert 'Frameworks:' in result + assert 'AppKit.framework' in result def testShowTargetExplicitBuildPhase(self): args = { @@ -167,7 +167,7 @@ def testShowTargetExplicitBuildPhase(self): project = open_project(args) result = pbxproj_show.execute(project, args) - self.assertIn('helloworld:', result) - self.assertIn('Product name: helloworld\n', result) - self.assertIn('Frameworks:', result) - self.assertIn('AppKit.framework', result) + assert 'helloworld:' in result + assert 'Product name: helloworld\n' in result + assert 'Frameworks:' in result + assert 'AppKit.framework' in result diff --git a/tests/pbxextensions/TestProjectFiles.py b/tests/pbxextensions/TestProjectFiles.py index 41e4f3cf..c0826869 100644 --- a/tests/pbxextensions/TestProjectFiles.py +++ b/tests/pbxextensions/TestProjectFiles.py @@ -5,6 +5,7 @@ from pbxproj import XcodeProject from pbxproj.pbxextensions import ProjectFiles, FileOptions, TreeType, HeaderScope from pbxproj.pbxsections import XCRemoteSwiftPackageReference, XCSwiftPackageProductDependency +import pytest class ProjectFilesTest(unittest.TestCase): def setUp(self): @@ -41,12 +42,12 @@ def setUp(self): } def testInit(self): - with self.assertRaisesRegex(EnvironmentError, '^This class cannot be instantiated directly'): + with pytest.raises(EnvironmentError, match='^This class cannot be instantiated directly'): ProjectFiles() def testAddFileUnknown(self): project = XcodeProject(self.obj) - with self.assertRaisesRegex(ValueError, '^Unknown file extension: '): + with pytest.raises(ValueError, match='^Unknown file extension: '): project.add_file("file.unknowntype") def testAddFileUnknownAllowed(self): @@ -54,15 +55,15 @@ def testAddFileUnknownAllowed(self): build_file = project.add_file("file.unknowntype", file_options=FileOptions(ignore_unknown_type=True)) # unknown files are added as resources - self.assertEqual(project.objects.get_objects_in_section(u'PBXResourcesBuildPhase').__len__(), 2) - self.assertEqual(build_file.__len__(), 2) + assert project.objects.get_objects_in_section(u'PBXResourcesBuildPhase').__len__() == 2 + assert build_file.__len__() == 2 def testAddFileNoPath(self): project = XcodeProject(self.obj) build_file = project.add_file(".", tree=None) # no tree or no path cannot be added - self.assertIsNone(build_file) + assert build_file is None def testAddFileNoCreateBuildFiles(self): project = XcodeProject(self.obj) @@ -70,16 +71,16 @@ def testAddFileNoCreateBuildFiles(self): build_file = project.add_file(".", file_options=FileOptions(create_build_files=False)) # no create build file flag - self.assertEqual(project.objects.__len__(), items) - self.assertEqual(build_file, []) + assert project.objects.__len__() == items + assert build_file == [] def testAddFileSource(self): project = XcodeProject(self.obj) build_file = project.add_file("file.m") # 2 source files are created 1 x target - self.assertEqual(project.objects.get_objects_in_section(u'PBXSourcesBuildPhase').__len__(), 2) - self.assertEqual(build_file.__len__(), 2) + assert project.objects.get_objects_in_section(u'PBXSourcesBuildPhase').__len__() == 2 + assert build_file.__len__() == 2 def testAddFileXCFrameworkEmbedded(self): project = XcodeProject(self.obj) @@ -87,13 +88,13 @@ def testAddFileXCFrameworkEmbedded(self): build_file = project.add_file("file.xcframework", file_options=options) # 2 source files are created 1 x target - self.assertEqual(project.objects.get_objects_in_section(u'PBXFrameworksBuildPhase').__len__(), 2) - self.assertEqual(project.objects.get_objects_in_section(u'PBXCopyFilesBuildPhase').__len__(), 3) - self.assertEqual(build_file.__len__(), 4) - self.assertListEqual(build_file[0].settings.ATTRIBUTES, [u'Weak']) - self.assertListEqual(build_file[1].settings.ATTRIBUTES, [u'CodeSignOnCopy', u'RemoveHeadersOnCopy']) - self.assertListEqual(build_file[2].settings.ATTRIBUTES, [u'Weak']) - self.assertListEqual(build_file[3].settings.ATTRIBUTES, [u'CodeSignOnCopy', u'RemoveHeadersOnCopy']) + assert project.objects.get_objects_in_section(u'PBXFrameworksBuildPhase').__len__() == 2 + assert project.objects.get_objects_in_section(u'PBXCopyFilesBuildPhase').__len__() == 3 + assert build_file.__len__() == 4 + assert build_file[0].settings.ATTRIBUTES == [u'Weak'] + assert build_file[1].settings.ATTRIBUTES == [u'CodeSignOnCopy', u'RemoveHeadersOnCopy'] + assert build_file[2].settings.ATTRIBUTES == [u'Weak'] + assert build_file[3].settings.ATTRIBUTES == [u'CodeSignOnCopy', u'RemoveHeadersOnCopy'] def testAddFileFrameworkEmbedded(self): project = XcodeProject(self.obj) @@ -101,13 +102,13 @@ def testAddFileFrameworkEmbedded(self): build_file = project.add_file("file.framework", file_options=options) # 2 source files are created 1 x target - self.assertEqual(project.objects.get_objects_in_section(u'PBXFrameworksBuildPhase').__len__(), 2) - self.assertEqual(project.objects.get_objects_in_section(u'PBXCopyFilesBuildPhase').__len__(), 3) - self.assertEqual(build_file.__len__(), 4) - self.assertListEqual(build_file[0].settings.ATTRIBUTES, [u'Weak']) - self.assertListEqual(build_file[1].settings.ATTRIBUTES, [u'CodeSignOnCopy', u'RemoveHeadersOnCopy']) - self.assertListEqual(build_file[2].settings.ATTRIBUTES, [u'Weak']) - self.assertListEqual(build_file[3].settings.ATTRIBUTES, [u'CodeSignOnCopy', u'RemoveHeadersOnCopy']) + assert project.objects.get_objects_in_section(u'PBXFrameworksBuildPhase').__len__() == 2 + assert project.objects.get_objects_in_section(u'PBXCopyFilesBuildPhase').__len__() == 3 + assert build_file.__len__() == 4 + assert build_file[0].settings.ATTRIBUTES == [u'Weak'] + assert build_file[1].settings.ATTRIBUTES == [u'CodeSignOnCopy', u'RemoveHeadersOnCopy'] + assert build_file[2].settings.ATTRIBUTES == [u'Weak'] + assert build_file[3].settings.ATTRIBUTES == [u'CodeSignOnCopy', u'RemoveHeadersOnCopy'] def testAddFileFrameworkFromSDKRootIgnoresEmbedAndCodeSign(self): project = XcodeProject(self.obj) @@ -115,79 +116,79 @@ def testAddFileFrameworkFromSDKRootIgnoresEmbedAndCodeSign(self): build_file = project.add_file("file.framework", tree=TreeType.SDKROOT, file_options=options) # 2 source files are created 1 x target - self.assertEqual(project.objects.get_objects_in_section(u'PBXFrameworksBuildPhase').__len__(), 2) - self.assertEqual(project.objects.get_objects_in_section(u'PBXCopyFilesBuildPhase').__len__(), 3) - self.assertEqual(build_file.__len__(), 4) - self.assertListEqual(build_file[0].settings.ATTRIBUTES, [u'Weak']) - self.assertIsNone(build_file[1]['settings']) - self.assertListEqual(build_file[2].settings.ATTRIBUTES, [u'Weak']) - self.assertIsNone(build_file[3]['settings']) + assert project.objects.get_objects_in_section(u'PBXFrameworksBuildPhase').__len__() == 2 + assert project.objects.get_objects_in_section(u'PBXCopyFilesBuildPhase').__len__() == 3 + assert build_file.__len__() == 4 + assert build_file[0].settings.ATTRIBUTES == [u'Weak'] + assert build_file[1]['settings'] is None + assert build_file[2].settings.ATTRIBUTES == [u'Weak'] + assert build_file[3]['settings'] is None def testAddFileFrameworkWithAbsolutePath(self): project = XcodeProject(self.obj) project.add_file(os.path.abspath("samples/test with spaces.framework")) expected_flags = ["$(SRCROOT)/tests/samples", "$(inherited)"] - self.assertListEqual(project.objects['5'].buildSettings.FRAMEWORK_SEARCH_PATHS, expected_flags) - self.assertListEqual(project.objects['6'].buildSettings.FRAMEWORK_SEARCH_PATHS, expected_flags) - self.assertListEqual(project.objects['7'].buildSettings.FRAMEWORK_SEARCH_PATHS, expected_flags) - self.assertListEqual(project.objects['8'].buildSettings.FRAMEWORK_SEARCH_PATHS, expected_flags) + assert project.objects['5'].buildSettings.FRAMEWORK_SEARCH_PATHS == expected_flags + assert project.objects['6'].buildSettings.FRAMEWORK_SEARCH_PATHS == expected_flags + assert project.objects['7'].buildSettings.FRAMEWORK_SEARCH_PATHS == expected_flags + assert project.objects['8'].buildSettings.FRAMEWORK_SEARCH_PATHS == expected_flags def testAddFileLibraryWithAbsolutePath(self): project = XcodeProject(self.obj) project.add_file(os.path.abspath("samples/path with spaces/testLibrary.a")) expected_flags = "\"$(SRCROOT)/tests/samples/path with spaces\"" - self.assertEqual(project.objects['5'].buildSettings.LIBRARY_SEARCH_PATHS, expected_flags) - self.assertEqual(project.objects['6'].buildSettings.LIBRARY_SEARCH_PATHS, expected_flags) - self.assertEqual(project.objects['7'].buildSettings.LIBRARY_SEARCH_PATHS, expected_flags) - self.assertEqual(project.objects['8'].buildSettings.LIBRARY_SEARCH_PATHS, expected_flags) + assert project.objects['5'].buildSettings.LIBRARY_SEARCH_PATHS == expected_flags + assert project.objects['6'].buildSettings.LIBRARY_SEARCH_PATHS == expected_flags + assert project.objects['7'].buildSettings.LIBRARY_SEARCH_PATHS == expected_flags + assert project.objects['8'].buildSettings.LIBRARY_SEARCH_PATHS == expected_flags def testAddFileWithAbsolutePathDoesNotExist(self): project = XcodeProject(self.obj) build_file = project.add_file(os.path.abspath("samples/unexistingFile.m")) # nothing to do if the file is absolute but doesn't exist - self.assertIsNone(build_file) + assert build_file is None def testAddFileWithAbsolutePathOnUnknownTree(self): project = XcodeProject(self.obj) build_file = project.add_file(os.path.abspath("samples/test with spaces.framework"), tree='DEVELOPER_DIR') - self.assertEqual(project.objects[build_file[0].fileRef].sourceTree, TreeType.ABSOLUTE) - self.assertEqual(project.objects[build_file[1].fileRef].sourceTree, TreeType.ABSOLUTE) - self.assertEqual(project.objects[build_file[2].fileRef].sourceTree, TreeType.ABSOLUTE) - self.assertEqual(project.objects[build_file[3].fileRef].sourceTree, TreeType.ABSOLUTE) + assert project.objects[build_file[0].fileRef].sourceTree == TreeType.ABSOLUTE + assert project.objects[build_file[1].fileRef].sourceTree == TreeType.ABSOLUTE + assert project.objects[build_file[2].fileRef].sourceTree == TreeType.ABSOLUTE + assert project.objects[build_file[3].fileRef].sourceTree == TreeType.ABSOLUTE def testAddReferenceFile(self): project = XcodeProject(self.obj, path="tests/project.pbxproj") build_file = project.add_file(os.path.abspath("samples/dirA")) - self.assertEqual(project.objects.get_objects_in_section(u'PBXResourcesBuildPhase').__len__(), 2) - self.assertEqual(build_file.__len__(), 2) + assert project.objects.get_objects_in_section(u'PBXResourcesBuildPhase').__len__() == 2 + assert build_file.__len__() == 2 def testAddFileIfExists(self): project = XcodeProject(self.obj) build_file = project.add_file("file.m", force=False) # 2 source files are created 1 x target - self.assertEqual(project.objects.get_objects_in_section(u'PBXSourcesBuildPhase').__len__(), 2) - self.assertEqual(build_file.__len__(), 2) + assert project.objects.get_objects_in_section(u'PBXSourcesBuildPhase').__len__() == 2 + assert build_file.__len__() == 2 build_file = project.add_file("file.m", force=False) - self.assertEqual(build_file, []) + assert build_file == [] def testAddFileIfExistsToMissingTargets(self): project = XcodeProject(self.obj) build_file = project.add_file("file.m", target_name='app', force=False) # 1 source files are created 1 x target - self.assertEqual(project.objects.get_objects_in_section(u'PBXSourcesBuildPhase').__len__(), 1) - self.assertEqual(build_file.__len__(), 1) + assert project.objects.get_objects_in_section(u'PBXSourcesBuildPhase').__len__() == 1 + assert build_file.__len__() == 1 build_file = project.add_file("file.m", force=False) - self.assertEqual(project.objects.get_objects_in_section(u'PBXSourcesBuildPhase').__len__(), 2) - self.assertEqual(build_file.__len__(), 1) + assert project.objects.get_objects_in_section(u'PBXSourcesBuildPhase').__len__() == 2 + assert build_file.__len__() == 1 def testAddFileOfAllTypes(self): for ext in ProjectFiles._FILE_TYPES: @@ -200,41 +201,41 @@ def testAddFileOfAllTypes(self): if phase is not None: amount = 2 - self.assertEqual(project.objects.get_objects_in_section(phase).__len__(), amount) - self.assertEqual(build_file.__len__(), amount) + assert project.objects.get_objects_in_section(phase).__len__() == amount + assert build_file.__len__() == amount def testGetFilesByNameWithNoParent(self): project = XcodeProject(self.obj) files = project.get_files_by_name('file') - self.assertEqual(files.__len__(), 3) + assert files.__len__() == 3 def testGetFilesByNameWithParent(self): project = XcodeProject(self.obj) files = project.get_files_by_name('file', 'group2') - self.assertEqual(files.__len__(), 2) + assert files.__len__() == 2 files = project.get_files_by_name('file', 'group3') - self.assertEqual(files.__len__(), 1) + assert files.__len__() == 1 def testGetFilesByNameWithoutName(self): project = XcodeProject(self.obj) files = project.get_files_by_name('file1') - self.assertEqual(files.__len__(), 2) + assert files.__len__() == 2 def testGetFileByPathWithNoTree(self): project = XcodeProject(self.obj) files = project.get_files_by_path('file') - self.assertEqual(files.__len__(), 2) + assert files.__len__() == 2 def testGetFileByPathWithTree(self): project = XcodeProject(self.obj) files = project.get_files_by_path('file', TreeType.SDKROOT) - self.assertEqual(files.__len__(), 1) + assert files.__len__() == 1 def testRemoveFileById(self): project = XcodeProject(self.obj) @@ -244,8 +245,8 @@ def testRemoveFileById(self): file = project.get_files_by_name('file.m')[0] result = project.remove_file_by_id(file.get_id()) - self.assertTrue(result) - self.assertEqual(project.__str__(), original) + assert result + assert project.__str__() == original def testRemoveFileByIdKeepShellScriptBuildPhases(self): project = XcodeProject(self.obj) @@ -257,8 +258,8 @@ def testRemoveFileByIdKeepShellScriptBuildPhases(self): file = project.get_files_by_name('file.m')[0] result = project.remove_file_by_id(file.get_id()) - self.assertTrue(result) - self.assertEqual(project.__str__(), original) + assert result + assert project.__str__() == original def testRemoveFileByIdFromTarget(self): project = XcodeProject(self.obj) @@ -267,16 +268,16 @@ def testRemoveFileByIdFromTarget(self): file_ref = project.get_files_by_name('file.m')[0] result = project.remove_file_by_id(file_ref.get_id(), target_name='report') - self.assertTrue(result) - self.assertIsNotNone(project.objects[file_ref.get_id()]) - self.assertEqual(project.objects.get_objects_in_section('PBXBuildFile').__len__(), 3) - self.assertEqual(project.objects.get_objects_in_section('PBXSourcesBuildPhase').__len__(), 1) + assert result + assert project.objects[file_ref.get_id()] is not None + assert project.objects.get_objects_in_section('PBXBuildFile').__len__() == 3 + assert project.objects.get_objects_in_section('PBXSourcesBuildPhase').__len__() == 1 def testRemoveFileByIdOnlyFiles(self): project = XcodeProject(self.obj) result = project.remove_file_by_id('group1') - self.assertFalse(result) + assert not result def testRemoveFilesByPath(self): project = XcodeProject(self.obj) @@ -285,14 +286,14 @@ def testRemoveFilesByPath(self): result = project.remove_files_by_path('file.m') - self.assertTrue(result) - self.assertEqual(project.__str__(), original) + assert result + assert project.__str__() == original def testAddFolderNotAFolder(self): project = XcodeProject(self.obj) result = project.add_folder('samples/testLibrary.a') - self.assertIsNone(result) + assert result is None def testAddFolderNonRecursive(self): project = XcodeProject(self.obj) @@ -302,12 +303,12 @@ def testAddFolderNonRecursive(self): samples = project.get_groups_by_name('samples') dir_a = project.get_groups_by_name('dirA') dir_b = project.get_groups_by_name('dirB') - self.assertNotEqual(samples, []) - self.assertNotEqual(dir_a, []) - self.assertEqual(dir_b, []) + assert samples != [] + assert dir_a != [] + assert dir_b == [] - self.assertEqual(samples[0].children.__len__(), 3) # dirA, test with spaces.framework, testLibrary.a - self.assertEqual(dir_a[0].children.__len__(), 0) + assert samples[0].children.__len__() == 3 # dirA, test with spaces.framework, testLibrary.a + assert dir_a[0].children.__len__() == 0 def testAddFolderRecursive(self): project = XcodeProject(self.obj) @@ -317,13 +318,13 @@ def testAddFolderRecursive(self): samples = project.get_groups_by_name('samples') dir_a = project.get_groups_by_name('dirA') dir_b = project.get_groups_by_name('dirB') - self.assertNotEqual(samples, []) - self.assertNotEqual(dir_a, []) - self.assertNotEqual(dir_b, []) + assert samples != [] + assert dir_a != [] + assert dir_b != [] - self.assertEqual(samples[0].children.__len__(), 3) # dirA, test with spaces.framework, testLibrary.a - self.assertEqual(dir_a[0].children.__len__(), 2) # dirB, fileA.m - self.assertEqual(dir_b[0].children.__len__(), 2) # fileB.m, fileB.h + assert samples[0].children.__len__() == 3 # dirA, test with spaces.framework, testLibrary.a + assert dir_a[0].children.__len__() == 2 # dirB, fileA.m + assert dir_b[0].children.__len__() == 2 # fileB.m, fileB.h def testAddFolderWithExclusions(self): project = XcodeProject(self.obj) @@ -333,21 +334,21 @@ def testAddFolderWithExclusions(self): samples = project.get_groups_by_name('samples') dir_a = project.get_groups_by_name('dirA') dir_b = project.get_groups_by_name('dirB') - self.assertNotEqual(samples, []) - self.assertNotEqual(dir_a, []) - self.assertNotEqual(dir_b, []) + assert samples != [] + assert dir_a != [] + assert dir_b != [] - self.assertEqual(samples[0].children.__len__(), 2) # dirA, -test with spaces.framework, -testLibrary.a - self.assertEqual(dir_a[0].children.__len__(), 1) # dirB, -fileA.m - self.assertEqual(dir_b[0].children.__len__(), 1) # -fileB.m, +fileB.h + assert samples[0].children.__len__() == 2 # dirA, -test with spaces.framework, -testLibrary.a + assert dir_a[0].children.__len__() == 1 # dirB, -fileA.m + assert dir_b[0].children.__len__() == 1 # -fileB.m, +fileB.h def testAddFolderAsReference(self): project = XcodeProject(self.obj, path="tests/project.pbxproj") build_file = project.add_folder('samples', create_groups=False) - self.assertListEqual(project.get_groups_by_name('samples'), []) - self.assertEqual(project.objects.get_objects_in_section(u'PBXResourcesBuildPhase').__len__(), 2) - self.assertEqual(build_file.__len__(), 2) + assert project.get_groups_by_name('samples') == [] + assert project.objects.get_objects_in_section(u'PBXResourcesBuildPhase').__len__() == 2 + assert build_file.__len__() == 2 def testAddFolderWithPathSameAsName(self): project = XcodeProject(self.obj, path="tests/project.pbxproj") @@ -359,17 +360,17 @@ def testAddFolderWithPathSameAsName(self): target_path = 'parent_group/samples' project.add_folder(parent=parent_group, path=target_path, file_options=FileOptions(add_groups_relative=False)) - self.assertEqual(project.get_or_create_group('samples').path, os.path.abspath(target_path)) + assert project.get_or_create_group('samples').path == os.path.abspath(target_path) shutil.rmtree('parent_group') def testEmbedFrameworkInRightCopySection(self): project = XcodeProject(self.obj) - self.assertEqual(project.objects.get_objects_in_section(u'PBXCopyFilesBuildPhase').__len__(), 1) + assert project.objects.get_objects_in_section(u'PBXCopyFilesBuildPhase').__len__() == 1 project.add_file('X.framework', file_options=FileOptions(embed_framework=True)) - self.assertEqual(project.objects.get_objects_in_section(u'PBXCopyFilesBuildPhase').__len__(), 3) + assert project.objects.get_objects_in_section(u'PBXCopyFilesBuildPhase').__len__() == 3 def testAddProjectWithBuildPhases(self): project = XcodeProject(self.obj) @@ -380,15 +381,15 @@ def testAddProjectWithBuildPhases(self): reference_proxies = project.add_project('samplescli/dependency.xcodeproj') - self.assertEqual(reference_proxies.__len__(), 2) - self.assertEqual(project.objects.get_objects_in_section(u'PBXContainerItemProxy').__len__(), 2) - self.assertEqual(project.objects.get_objects_in_section(u'PBXReferenceProxy').__len__(), 2) - self.assertEqual(project.objects.get_objects_in_section(u'PBXProject')[0].projectReferences.__len__(), 1) + assert reference_proxies.__len__() == 2 + assert project.objects.get_objects_in_section(u'PBXContainerItemProxy').__len__() == 2 + assert project.objects.get_objects_in_section(u'PBXReferenceProxy').__len__() == 2 + assert project.objects.get_objects_in_section(u'PBXProject')[0].projectReferences.__len__() == 1 # check that the buildFiles where added - self.assertGreater(project.objects.get_objects_in_section('PBXBuildFile').__len__(), build_files) - self.assertGreater(project.objects.get_objects_in_section('PBXFrameworksBuildPhase').__len__(), frameworks) - self.assertGreater(project.objects.get_objects_in_section('PBXResourcesBuildPhase').__len__(), resources) + assert project.objects.get_objects_in_section('PBXBuildFile').__len__() > build_files + assert project.objects.get_objects_in_section('PBXFrameworksBuildPhase').__len__() > frameworks + assert project.objects.get_objects_in_section('PBXResourcesBuildPhase').__len__() > resources def testAddProjectWithoutBuildPhases(self): project = XcodeProject(self.obj) @@ -399,15 +400,15 @@ def testAddProjectWithoutBuildPhases(self): reference_proxies = project.add_project('samplescli/dependency.xcodeproj', file_options=FileOptions(create_build_files=False)) - self.assertEqual(reference_proxies.__len__(), 2) - self.assertEqual(project.objects.get_objects_in_section(u'PBXContainerItemProxy').__len__(), 2) - self.assertEqual(project.objects.get_objects_in_section(u'PBXReferenceProxy').__len__(), 2) - self.assertEqual(project.objects.get_objects_in_section(u'PBXProject')[0].projectReferences.__len__(), 1) + assert reference_proxies.__len__() == 2 + assert project.objects.get_objects_in_section(u'PBXContainerItemProxy').__len__() == 2 + assert project.objects.get_objects_in_section(u'PBXReferenceProxy').__len__() == 2 + assert project.objects.get_objects_in_section(u'PBXProject')[0].projectReferences.__len__() == 1 # check that the buildFiles where added - self.assertEqual(project.objects.get_objects_in_section('PBXBuildFile').__len__(), build_files) - self.assertEqual(project.objects.get_objects_in_section('PBXFrameworksBuildPhase').__len__(), frameworks) - self.assertEqual(project.objects.get_objects_in_section('PBXResourcesBuildPhase').__len__(), resources) + assert project.objects.get_objects_in_section('PBXBuildFile').__len__() == build_files + assert project.objects.get_objects_in_section('PBXFrameworksBuildPhase').__len__() == frameworks + assert project.objects.get_objects_in_section('PBXResourcesBuildPhase').__len__() == resources def testAddProjectNotForced(self): project = XcodeProject(self.obj) @@ -416,14 +417,14 @@ def testAddProjectNotForced(self): reference_proxies = project.add_project('samplescli/dependency.xcodeproj', force=False, file_options=FileOptions(create_build_files=False)) - self.assertListEqual(reference_proxies, []) + assert reference_proxies == [] def testAddProjectDoesntExists(self): project = XcodeProject(self.obj) reference_proxies = project.add_project(os.path.abspath("samples/unexistingFile.m")) # nothing to do if the file is absolute but doesn't exist - self.assertIsNone(reference_proxies) + assert reference_proxies is None def testAddHeaderFilePublic(self): project = XcodeProject({ @@ -437,12 +438,12 @@ def testAddHeaderFilePublic(self): } }) - self.assertEqual(project.get_build_phases_by_name(u'PBXHeadersBuildPhase').__len__(), 0) + assert project.get_build_phases_by_name(u'PBXHeadersBuildPhase').__len__() == 0 references = project.add_file("header.h", file_options=FileOptions(header_scope=HeaderScope.PUBLIC)) - self.assertGreater(project.get_build_phases_by_name(u'PBXHeadersBuildPhase').__len__(), 0) - self.assertListEqual(references[0].settings.ATTRIBUTES, ['Public']) + assert project.get_build_phases_by_name(u'PBXHeadersBuildPhase').__len__() > 0 + assert references[0].settings.ATTRIBUTES == ['Public'] def testAddHeaderFilePrivate(self): @@ -457,12 +458,12 @@ def testAddHeaderFilePrivate(self): } }) - self.assertEqual(project.get_build_phases_by_name(u'PBXHeadersBuildPhase').__len__(), 0) + assert project.get_build_phases_by_name(u'PBXHeadersBuildPhase').__len__() == 0 references = project.add_file("header.h", file_options=FileOptions(header_scope=HeaderScope.PRIVATE)) - self.assertGreater(project.get_build_phases_by_name(u'PBXHeadersBuildPhase').__len__(), 0) - self.assertListEqual(references[0].settings.ATTRIBUTES, ['Private']) + assert project.get_build_phases_by_name(u'PBXHeadersBuildPhase').__len__() > 0 + assert references[0].settings.ATTRIBUTES == ['Private'] def testAddHeaderFileProjectScope(self): project = XcodeProject({ @@ -476,12 +477,12 @@ def testAddHeaderFileProjectScope(self): } }) - self.assertEqual(project.get_build_phases_by_name(u'PBXHeadersBuildPhase').__len__(), 0) + assert project.get_build_phases_by_name(u'PBXHeadersBuildPhase').__len__() == 0 references = project.add_file("header.h", file_options=FileOptions()) - self.assertGreater(project.get_build_phases_by_name(u'PBXHeadersBuildPhase').__len__(), 0) - self.assertIsNone(references[0]['settings'], None) + assert project.get_build_phases_by_name(u'PBXHeadersBuildPhase').__len__() > 0 + assert references[0]['settings'] is None, None def testAddPackage(self): project = XcodeProject({ @@ -495,14 +496,14 @@ def testAddPackage(self): "minimumVersion": "5.0.1"}, 'some-package', 'app') # create swift package reference and its entry into PBXProject package references - self.assertIsInstance(results[0], XCRemoteSwiftPackageReference) - self.assertEqual(project.objects.get_objects_in_section('PBXProject')[0].packageReferences.__len__(), 1) + assert isinstance(results[0], XCRemoteSwiftPackageReference) + assert project.objects.get_objects_in_section('PBXProject')[0].packageReferences.__len__() == 1 # create package product dependency and its entry into PBXNativeTarget package product depedency, # PBXBuildFile and PBXFrameworksBuildPhase - self.assertIsInstance(results[1], XCSwiftPackageProductDependency) - self.assertEqual(project.objects.get_objects_in_section('PBXFrameworksBuildPhase')[0].files.__len__(), 1) - self.assertEqual(project.objects.get_objects_in_section('PBXNativeTarget')[0].packageProductDependencies.__len__(), 1) - self.assertEqual(project.objects.get_objects_in_section('PBXBuildFile').__len__(), 1) + assert isinstance(results[1], XCSwiftPackageProductDependency) + assert project.objects.get_objects_in_section('PBXFrameworksBuildPhase')[0].files.__len__() == 1 + assert project.objects.get_objects_in_section('PBXNativeTarget')[0].packageProductDependencies.__len__() == 1 + assert project.objects.get_objects_in_section('PBXBuildFile').__len__() == 1 def testAddPackageWithTwoProducts(self): project = XcodeProject({ @@ -517,11 +518,11 @@ def testAddPackageWithTwoProducts(self): # create two package product dependency and their entry into PBXNativeTarget package product depedency, # PBXBuildFile and PBXFrameworksBuildPhase - self.assertIsInstance(results[1], XCSwiftPackageProductDependency) - self.assertIsInstance(results[2], XCSwiftPackageProductDependency) - self.assertEqual(project.objects.get_objects_in_section('PBXFrameworksBuildPhase')[0].files.__len__(), 2) - self.assertEqual(project.objects.get_objects_in_section('PBXNativeTarget')[0].packageProductDependencies.__len__(), 2) - self.assertEqual(project.objects.get_objects_in_section('PBXBuildFile').__len__(), 2) + assert isinstance(results[1], XCSwiftPackageProductDependency) + assert isinstance(results[2], XCSwiftPackageProductDependency) + assert project.objects.get_objects_in_section('PBXFrameworksBuildPhase')[0].files.__len__() == 2 + assert project.objects.get_objects_in_section('PBXNativeTarget')[0].packageProductDependencies.__len__() == 2 + assert project.objects.get_objects_in_section('PBXBuildFile').__len__() == 2 def testGetPackageReference(self): project = XcodeProject({ @@ -531,7 +532,7 @@ def testGetPackageReference(self): }) result = project.get_or_create_package_reference('http://myrepo.com/some-package', {}) - self.assertIsNotNone(result) + assert result is not None def testGetPackageDependency(self): project = XcodeProject({ @@ -541,4 +542,4 @@ def testGetPackageDependency(self): }) result = project.get_or_create_package_dependency('Some Product', '', {}) - self.assertIsNotNone(result) + assert result is not None diff --git a/tests/pbxextensions/TestProjectFlags.py b/tests/pbxextensions/TestProjectFlags.py index 27b0dbc1..20834f90 100644 --- a/tests/pbxextensions/TestProjectFlags.py +++ b/tests/pbxextensions/TestProjectFlags.py @@ -2,6 +2,7 @@ from pbxproj import XcodeProject, PBXProvisioningTypes from pbxproj.pbxextensions import ProjectFlags +import pytest LS_LA_COMMAND = u'ls -la' PATH_TO_SEARCH_PATTERN = 'path/to/search/**' @@ -31,290 +32,290 @@ def setUp(self): } def testInit(self): - with self.assertRaisesRegex(EnvironmentError, '^This class cannot be instantiated directly'): + with pytest.raises(EnvironmentError, match='^This class cannot be instantiated directly'): ProjectFlags() def testAddFlags(self): project = XcodeProject(self.obj) project.add_flags('flag', '-flag') - self.assertEqual(project.objects['5'].buildSettings.flag, '-flag') - self.assertEqual(project.objects['6'].buildSettings.flag, '-flag') - self.assertEqual(project.objects['7'].buildSettings.flag, '-flag') - self.assertEqual(project.objects['8'].buildSettings.flag, '-flag') + assert project.objects['5'].buildSettings.flag == '-flag' + assert project.objects['6'].buildSettings.flag == '-flag' + assert project.objects['7'].buildSettings.flag == '-flag' + assert project.objects['8'].buildSettings.flag == '-flag' def testAddProjectFlags(self): project = XcodeProject(self.obj) project.add_project_flags('flag', '-flag') - self.assertEqual(project.objects['9'].buildSettings.flag, '-flag') - self.assertEqual(project.objects['10'].buildSettings.flag, '-flag') + assert project.objects['9'].buildSettings.flag == '-flag' + assert project.objects['10'].buildSettings.flag == '-flag' def testRemoveFlags(self): project = XcodeProject(self.obj) project.remove_flags('base', 'a') - self.assertIsNone(project.objects['5'].buildSettings['base']) + assert project.objects['5'].buildSettings['base'] is None def testRemoveProjectFlags(self): project = XcodeProject(self.obj) project.remove_project_flags('base', 'x') - self.assertIsNone(project.objects['10'].buildSettings['base']) + assert project.objects['10'].buildSettings['base'] is None def testAddOtherCFlags(self): project = XcodeProject(self.obj) project.add_other_cflags('-ObjC') - self.assertEqual(project.objects['5'].buildSettings.OTHER_CFLAGS, '-ObjC') - self.assertEqual(project.objects['6'].buildSettings.OTHER_CFLAGS, '-ObjC') - self.assertEqual(project.objects['7'].buildSettings.OTHER_CFLAGS, '-ObjC') - self.assertEqual(project.objects['8'].buildSettings.OTHER_CFLAGS, '-ObjC') + assert project.objects['5'].buildSettings.OTHER_CFLAGS == '-ObjC' + assert project.objects['6'].buildSettings.OTHER_CFLAGS == '-ObjC' + assert project.objects['7'].buildSettings.OTHER_CFLAGS == '-ObjC' + assert project.objects['8'].buildSettings.OTHER_CFLAGS == '-ObjC' def testAddOtherLDFlags(self): project = XcodeProject(self.obj) project.add_other_ldflags('-ObjC') - self.assertEqual(project.objects['5'].buildSettings.OTHER_LDFLAGS, '-ObjC') - self.assertEqual(project.objects['6'].buildSettings.OTHER_LDFLAGS, '-ObjC') - self.assertEqual(project.objects['7'].buildSettings.OTHER_LDFLAGS, '-ObjC') - self.assertEqual(project.objects['8'].buildSettings.OTHER_LDFLAGS, '-ObjC') + assert project.objects['5'].buildSettings.OTHER_LDFLAGS == '-ObjC' + assert project.objects['6'].buildSettings.OTHER_LDFLAGS == '-ObjC' + assert project.objects['7'].buildSettings.OTHER_LDFLAGS == '-ObjC' + assert project.objects['8'].buildSettings.OTHER_LDFLAGS == '-ObjC' def testRemoveOtherCFlags(self): project = XcodeProject(self.obj) project.add_other_cflags('-ObjC') - self.assertEqual(project.objects['5'].buildSettings.OTHER_CFLAGS, '-ObjC') - self.assertEqual(project.objects['6'].buildSettings.OTHER_CFLAGS, '-ObjC') - self.assertEqual(project.objects['7'].buildSettings.OTHER_CFLAGS, '-ObjC') - self.assertEqual(project.objects['8'].buildSettings.OTHER_CFLAGS, '-ObjC') + assert project.objects['5'].buildSettings.OTHER_CFLAGS == '-ObjC' + assert project.objects['6'].buildSettings.OTHER_CFLAGS == '-ObjC' + assert project.objects['7'].buildSettings.OTHER_CFLAGS == '-ObjC' + assert project.objects['8'].buildSettings.OTHER_CFLAGS == '-ObjC' project.remove_other_cflags('-ObjC') - self.assertIsNone(project.objects['5'].buildSettings['OTHER_CFLAGS']) - self.assertIsNone(project.objects['6'].buildSettings['OTHER_CFLAGS']) - self.assertIsNone(project.objects['7'].buildSettings['OTHER_CFLAGS']) - self.assertIsNone(project.objects['8'].buildSettings['OTHER_CFLAGS']) + assert project.objects['5'].buildSettings['OTHER_CFLAGS'] is None + assert project.objects['6'].buildSettings['OTHER_CFLAGS'] is None + assert project.objects['7'].buildSettings['OTHER_CFLAGS'] is None + assert project.objects['8'].buildSettings['OTHER_CFLAGS'] is None def testRemoveOtherLDFlags(self): project = XcodeProject(self.obj) project.add_other_ldflags('-ObjC') - self.assertEqual(project.objects['5'].buildSettings.OTHER_LDFLAGS, '-ObjC') - self.assertEqual(project.objects['6'].buildSettings.OTHER_LDFLAGS, '-ObjC') - self.assertEqual(project.objects['7'].buildSettings.OTHER_LDFLAGS, '-ObjC') - self.assertEqual(project.objects['8'].buildSettings.OTHER_LDFLAGS, '-ObjC') + assert project.objects['5'].buildSettings.OTHER_LDFLAGS == '-ObjC' + assert project.objects['6'].buildSettings.OTHER_LDFLAGS == '-ObjC' + assert project.objects['7'].buildSettings.OTHER_LDFLAGS == '-ObjC' + assert project.objects['8'].buildSettings.OTHER_LDFLAGS == '-ObjC' project.remove_other_ldflags('-ObjC') - self.assertIsNone(project.objects['5'].buildSettings['OTHER_LDFLAGS']) - self.assertIsNone(project.objects['6'].buildSettings['OTHER_LDFLAGS']) - self.assertIsNone(project.objects['7'].buildSettings['OTHER_LDFLAGS']) - self.assertIsNone(project.objects['8'].buildSettings['OTHER_LDFLAGS']) + assert project.objects['5'].buildSettings['OTHER_LDFLAGS'] is None + assert project.objects['6'].buildSettings['OTHER_LDFLAGS'] is None + assert project.objects['7'].buildSettings['OTHER_LDFLAGS'] is None + assert project.objects['8'].buildSettings['OTHER_LDFLAGS'] is None def testAddHeaderSearchPaths(self): project = XcodeProject(self.obj) project.add_header_search_paths('path/to/search') - self.assertEqual(project.objects['5'].buildSettings.HEADER_SEARCH_PATHS, PATH_TO_SEARCH_PATTERN) - self.assertEqual(project.objects['6'].buildSettings.HEADER_SEARCH_PATHS, PATH_TO_SEARCH_PATTERN) - self.assertEqual(project.objects['7'].buildSettings.HEADER_SEARCH_PATHS, PATH_TO_SEARCH_PATTERN) - self.assertEqual(project.objects['8'].buildSettings.HEADER_SEARCH_PATHS, PATH_TO_SEARCH_PATTERN) + assert project.objects['5'].buildSettings.HEADER_SEARCH_PATHS == PATH_TO_SEARCH_PATTERN + assert project.objects['6'].buildSettings.HEADER_SEARCH_PATHS == PATH_TO_SEARCH_PATTERN + assert project.objects['7'].buildSettings.HEADER_SEARCH_PATHS == PATH_TO_SEARCH_PATTERN + assert project.objects['8'].buildSettings.HEADER_SEARCH_PATHS == PATH_TO_SEARCH_PATTERN def testAddLibrarySearchPaths(self): project = XcodeProject(self.obj) project.add_library_search_paths('path/to/search') - self.assertEqual(project.objects['5'].buildSettings.LIBRARY_SEARCH_PATHS, PATH_TO_SEARCH_PATTERN) - self.assertEqual(project.objects['6'].buildSettings.LIBRARY_SEARCH_PATHS, PATH_TO_SEARCH_PATTERN) - self.assertEqual(project.objects['7'].buildSettings.LIBRARY_SEARCH_PATHS, PATH_TO_SEARCH_PATTERN) - self.assertEqual(project.objects['8'].buildSettings.LIBRARY_SEARCH_PATHS, PATH_TO_SEARCH_PATTERN) + assert project.objects['5'].buildSettings.LIBRARY_SEARCH_PATHS == PATH_TO_SEARCH_PATTERN + assert project.objects['6'].buildSettings.LIBRARY_SEARCH_PATHS == PATH_TO_SEARCH_PATTERN + assert project.objects['7'].buildSettings.LIBRARY_SEARCH_PATHS == PATH_TO_SEARCH_PATTERN + assert project.objects['8'].buildSettings.LIBRARY_SEARCH_PATHS == PATH_TO_SEARCH_PATTERN def testAddFrameworkSearchPaths(self): project = XcodeProject(self.obj) project.add_framework_search_paths('path/to/search') - self.assertEqual(project.objects['5'].buildSettings.FRAMEWORK_SEARCH_PATHS, PATH_TO_SEARCH_PATTERN) - self.assertEqual(project.objects['6'].buildSettings.FRAMEWORK_SEARCH_PATHS, PATH_TO_SEARCH_PATTERN) - self.assertEqual(project.objects['7'].buildSettings.FRAMEWORK_SEARCH_PATHS, PATH_TO_SEARCH_PATTERN) - self.assertEqual(project.objects['8'].buildSettings.FRAMEWORK_SEARCH_PATHS, PATH_TO_SEARCH_PATTERN) + assert project.objects['5'].buildSettings.FRAMEWORK_SEARCH_PATHS == PATH_TO_SEARCH_PATTERN + assert project.objects['6'].buildSettings.FRAMEWORK_SEARCH_PATHS == PATH_TO_SEARCH_PATTERN + assert project.objects['7'].buildSettings.FRAMEWORK_SEARCH_PATHS == PATH_TO_SEARCH_PATTERN + assert project.objects['8'].buildSettings.FRAMEWORK_SEARCH_PATHS == PATH_TO_SEARCH_PATTERN def testRemoveHeaderSearchPaths(self): project = XcodeProject(self.obj) project.add_header_search_paths('path/to/search') - self.assertEqual(project.objects['5'].buildSettings.HEADER_SEARCH_PATHS, PATH_TO_SEARCH_PATTERN) - self.assertEqual(project.objects['6'].buildSettings.HEADER_SEARCH_PATHS, PATH_TO_SEARCH_PATTERN) - self.assertEqual(project.objects['7'].buildSettings.HEADER_SEARCH_PATHS, PATH_TO_SEARCH_PATTERN) - self.assertEqual(project.objects['8'].buildSettings.HEADER_SEARCH_PATHS, PATH_TO_SEARCH_PATTERN) + assert project.objects['5'].buildSettings.HEADER_SEARCH_PATHS == PATH_TO_SEARCH_PATTERN + assert project.objects['6'].buildSettings.HEADER_SEARCH_PATHS == PATH_TO_SEARCH_PATTERN + assert project.objects['7'].buildSettings.HEADER_SEARCH_PATHS == PATH_TO_SEARCH_PATTERN + assert project.objects['8'].buildSettings.HEADER_SEARCH_PATHS == PATH_TO_SEARCH_PATTERN project.remove_header_search_paths(PATH_TO_SEARCH_PATTERN) - self.assertIsNone(project.objects['5'].buildSettings['HEADER_SEARCH_PATHS']) - self.assertIsNone(project.objects['6'].buildSettings['HEADER_SEARCH_PATHS']) - self.assertIsNone(project.objects['7'].buildSettings['HEADER_SEARCH_PATHS']) - self.assertIsNone(project.objects['8'].buildSettings['HEADER_SEARCH_PATHS']) + assert project.objects['5'].buildSettings['HEADER_SEARCH_PATHS'] is None + assert project.objects['6'].buildSettings['HEADER_SEARCH_PATHS'] is None + assert project.objects['7'].buildSettings['HEADER_SEARCH_PATHS'] is None + assert project.objects['8'].buildSettings['HEADER_SEARCH_PATHS'] is None def testRemoveLibrarySearchPaths(self): project = XcodeProject(self.obj) project.add_library_search_paths('path/to/search') - self.assertEqual(project.objects['5'].buildSettings.LIBRARY_SEARCH_PATHS, PATH_TO_SEARCH_PATTERN) - self.assertEqual(project.objects['6'].buildSettings.LIBRARY_SEARCH_PATHS, PATH_TO_SEARCH_PATTERN) - self.assertEqual(project.objects['7'].buildSettings.LIBRARY_SEARCH_PATHS, PATH_TO_SEARCH_PATTERN) - self.assertEqual(project.objects['8'].buildSettings.LIBRARY_SEARCH_PATHS, PATH_TO_SEARCH_PATTERN) + assert project.objects['5'].buildSettings.LIBRARY_SEARCH_PATHS == PATH_TO_SEARCH_PATTERN + assert project.objects['6'].buildSettings.LIBRARY_SEARCH_PATHS == PATH_TO_SEARCH_PATTERN + assert project.objects['7'].buildSettings.LIBRARY_SEARCH_PATHS == PATH_TO_SEARCH_PATTERN + assert project.objects['8'].buildSettings.LIBRARY_SEARCH_PATHS == PATH_TO_SEARCH_PATTERN project.remove_library_search_paths(PATH_TO_SEARCH_PATTERN) - self.assertIsNone(project.objects['5'].buildSettings['LIBRARY_SEARCH_PATHS']) - self.assertIsNone(project.objects['6'].buildSettings['LIBRARY_SEARCH_PATHS']) - self.assertIsNone(project.objects['7'].buildSettings['LIBRARY_SEARCH_PATHS']) - self.assertIsNone(project.objects['8'].buildSettings['LIBRARY_SEARCH_PATHS']) + assert project.objects['5'].buildSettings['LIBRARY_SEARCH_PATHS'] is None + assert project.objects['6'].buildSettings['LIBRARY_SEARCH_PATHS'] is None + assert project.objects['7'].buildSettings['LIBRARY_SEARCH_PATHS'] is None + assert project.objects['8'].buildSettings['LIBRARY_SEARCH_PATHS'] is None def testRemoveFrameworkSearchPaths(self): project = XcodeProject(self.obj) project.add_framework_search_paths('path/to/search') - self.assertEqual(project.objects['5'].buildSettings.FRAMEWORK_SEARCH_PATHS, PATH_TO_SEARCH_PATTERN) - self.assertEqual(project.objects['6'].buildSettings.FRAMEWORK_SEARCH_PATHS, PATH_TO_SEARCH_PATTERN) - self.assertEqual(project.objects['7'].buildSettings.FRAMEWORK_SEARCH_PATHS, PATH_TO_SEARCH_PATTERN) - self.assertEqual(project.objects['8'].buildSettings.FRAMEWORK_SEARCH_PATHS, PATH_TO_SEARCH_PATTERN) + assert project.objects['5'].buildSettings.FRAMEWORK_SEARCH_PATHS == PATH_TO_SEARCH_PATTERN + assert project.objects['6'].buildSettings.FRAMEWORK_SEARCH_PATHS == PATH_TO_SEARCH_PATTERN + assert project.objects['7'].buildSettings.FRAMEWORK_SEARCH_PATHS == PATH_TO_SEARCH_PATTERN + assert project.objects['8'].buildSettings.FRAMEWORK_SEARCH_PATHS == PATH_TO_SEARCH_PATTERN project.remove_framework_search_paths(PATH_TO_SEARCH_PATTERN) - self.assertIsNone(project.objects['5'].buildSettings['FRAMEWORK_SEARCH_PATHS']) - self.assertIsNone(project.objects['6'].buildSettings['FRAMEWORK_SEARCH_PATHS']) - self.assertIsNone(project.objects['7'].buildSettings['FRAMEWORK_SEARCH_PATHS']) - self.assertIsNone(project.objects['8'].buildSettings['FRAMEWORK_SEARCH_PATHS']) + assert project.objects['5'].buildSettings['FRAMEWORK_SEARCH_PATHS'] is None + assert project.objects['6'].buildSettings['FRAMEWORK_SEARCH_PATHS'] is None + assert project.objects['7'].buildSettings['FRAMEWORK_SEARCH_PATHS'] is None + assert project.objects['8'].buildSettings['FRAMEWORK_SEARCH_PATHS'] is None def testAddRunScriptBeforeCompile(self): project = XcodeProject(self.obj) project.add_run_script(LS_LA_COMMAND, insert_before_compile=True) - self.assertEqual(project.objects[project.objects['1'].buildPhases[0]].shellScript, LS_LA_COMMAND) - self.assertEqual(project.objects[project.objects['2'].buildPhases[0]].shellScript, LS_LA_COMMAND) + assert project.objects[project.objects['1'].buildPhases[0]].shellScript == LS_LA_COMMAND + assert project.objects[project.objects['2'].buildPhases[0]].shellScript == LS_LA_COMMAND def testAddRunScriptAfterCompile(self): project = XcodeProject(self.obj) project.add_run_script(LS_LA_COMMAND) - self.assertEqual(project.objects[project.objects['1'].buildPhases[1]].shellScript, LS_LA_COMMAND) - self.assertEqual(project.objects[project.objects['2'].buildPhases[1]].shellScript, LS_LA_COMMAND) + assert project.objects[project.objects['1'].buildPhases[1]].shellScript == LS_LA_COMMAND + assert project.objects[project.objects['2'].buildPhases[1]].shellScript == LS_LA_COMMAND def testAddRunScriptWithInputFiles(self): project = XcodeProject(self.obj) script = u'ls -la ${SCRIPT_INPUT_FILE_0} ${SCRIPT_INPUT_FILE_1} > ${SCRIPT_OUTPUT_FILE_0}' project.add_run_script(script, input_files=['a.txt', '/tmp/b.txt'], output_files=['../output.log']) - self.assertEqual(project.objects[project.objects['1'].buildPhases[1]].shellScript, script) - self.assertEqual(project.objects[project.objects['1'].buildPhases[1]].inputPaths, ['a.txt', '/tmp/b.txt']) - self.assertEqual(project.objects[project.objects['1'].buildPhases[1]].outputPaths, ['../output.log']) - self.assertEqual(project.objects[project.objects['2'].buildPhases[1]].shellScript, script) - self.assertEqual(project.objects[project.objects['2'].buildPhases[1]].inputPaths, ['a.txt', '/tmp/b.txt']) - self.assertEqual(project.objects[project.objects['2'].buildPhases[1]].outputPaths, ['../output.log']) + assert project.objects[project.objects['1'].buildPhases[1]].shellScript == script + assert project.objects[project.objects['1'].buildPhases[1]].inputPaths == ['a.txt', '/tmp/b.txt'] + assert project.objects[project.objects['1'].buildPhases[1]].outputPaths == ['../output.log'] + assert project.objects[project.objects['2'].buildPhases[1]].shellScript == script + assert project.objects[project.objects['2'].buildPhases[1]].inputPaths == ['a.txt', '/tmp/b.txt'] + assert project.objects[project.objects['2'].buildPhases[1]].outputPaths == ['../output.log'] def testRemoveRunScript(self): project = XcodeProject(self.obj) project.add_run_script(LS_LA_COMMAND, insert_before_compile=True) - self.assertEqual(project.objects[project.objects['1'].buildPhases[0]].shellScript, LS_LA_COMMAND) - self.assertEqual(project.objects[project.objects['2'].buildPhases[0]].shellScript, LS_LA_COMMAND) + assert project.objects[project.objects['1'].buildPhases[0]].shellScript == LS_LA_COMMAND + assert project.objects[project.objects['2'].buildPhases[0]].shellScript == LS_LA_COMMAND project.remove_run_script(LS_LA_COMMAND) - self.assertEqual(project.objects['1'].buildPhases[0], u'compile') - self.assertEqual(project.objects['2'].buildPhases[0], u'compile') + assert project.objects['1'].buildPhases[0] == u'compile' + assert project.objects['2'].buildPhases[0] == u'compile' def testRemoveRunScriptNotFound(self): project = XcodeProject(self.obj) project.add_run_script(LS_LA_COMMAND, insert_before_compile=True) - self.assertEqual(project.objects[project.objects['1'].buildPhases[0]].shellScript, LS_LA_COMMAND) - self.assertEqual(project.objects[project.objects['2'].buildPhases[0]].shellScript, LS_LA_COMMAND) + assert project.objects[project.objects['1'].buildPhases[0]].shellScript == LS_LA_COMMAND + assert project.objects[project.objects['2'].buildPhases[0]].shellScript == LS_LA_COMMAND project.remove_run_script(u'ls') - self.assertEqual(project.objects[project.objects['1'].buildPhases[0]].shellScript, LS_LA_COMMAND) - self.assertEqual(project.objects[project.objects['2'].buildPhases[0]].shellScript, LS_LA_COMMAND) + assert project.objects[project.objects['1'].buildPhases[0]].shellScript == LS_LA_COMMAND + assert project.objects[project.objects['2'].buildPhases[0]].shellScript == LS_LA_COMMAND def testAddRunScriptWithoutInstallBuild(self): project = XcodeProject(self.obj) project.add_run_script(LS_LA_COMMAND, run_install_build=0) - self.assertEqual(project.objects[project.objects['2'].buildPhases[1]].runOnlyForDeploymentPostprocessing, 0) + assert project.objects[project.objects['2'].buildPhases[1]].runOnlyForDeploymentPostprocessing == 0 def testAddRunScriptWithInstallBuild(self): project = XcodeProject(self.obj) project.add_run_script(LS_LA_COMMAND, run_install_build=1) - self.assertEqual(project.objects[project.objects['1'].buildPhases[1]].runOnlyForDeploymentPostprocessing, 1) + assert project.objects[project.objects['1'].buildPhases[1]].runOnlyForDeploymentPostprocessing == 1 def testAddCodeSignAllTargetAllConfigurations(self): project = XcodeProject(self.obj) project.add_code_sign('iPhone Distribution', 'MYTEAM', '0x0x0x0x0', 'Provisioning name') - self.assertEqual(project.objects['0'].attributes.TargetAttributes[u'1'].ProvisioningStyle, PBXProvisioningTypes.MANUAL) - self.assertEqual(project.objects['0'].attributes.TargetAttributes[u'2'].ProvisioningStyle, - PBXProvisioningTypes.MANUAL) + assert project.objects['0'].attributes.TargetAttributes[u'1'].ProvisioningStyle == PBXProvisioningTypes.MANUAL + assert project.objects['0'].attributes.TargetAttributes[u'2'].ProvisioningStyle == \ + PBXProvisioningTypes.MANUAL - self.assertEqual(project.objects['5'].buildSettings['CODE_SIGN_IDENTITY[sdk=iphoneos*]'], 'iPhone Distribution') - self.assertEqual(project.objects['6'].buildSettings['CODE_SIGN_IDENTITY[sdk=iphoneos*]'], 'iPhone Distribution') - self.assertEqual(project.objects['7'].buildSettings['CODE_SIGN_IDENTITY[sdk=iphoneos*]'], 'iPhone Distribution') - self.assertEqual(project.objects['8'].buildSettings['CODE_SIGN_IDENTITY[sdk=iphoneos*]'], 'iPhone Distribution') + assert project.objects['5'].buildSettings['CODE_SIGN_IDENTITY[sdk=iphoneos*]'] == 'iPhone Distribution' + assert project.objects['6'].buildSettings['CODE_SIGN_IDENTITY[sdk=iphoneos*]'] == 'iPhone Distribution' + assert project.objects['7'].buildSettings['CODE_SIGN_IDENTITY[sdk=iphoneos*]'] == 'iPhone Distribution' + assert project.objects['8'].buildSettings['CODE_SIGN_IDENTITY[sdk=iphoneos*]'] == 'iPhone Distribution' - self.assertEqual(project.objects['5'].buildSettings['DEVELOPMENT_TEAM'], 'MYTEAM') - self.assertEqual(project.objects['6'].buildSettings['DEVELOPMENT_TEAM'], 'MYTEAM') - self.assertEqual(project.objects['7'].buildSettings['DEVELOPMENT_TEAM'], 'MYTEAM') - self.assertEqual(project.objects['8'].buildSettings['DEVELOPMENT_TEAM'], 'MYTEAM') + assert project.objects['5'].buildSettings['DEVELOPMENT_TEAM'] == 'MYTEAM' + assert project.objects['6'].buildSettings['DEVELOPMENT_TEAM'] == 'MYTEAM' + assert project.objects['7'].buildSettings['DEVELOPMENT_TEAM'] == 'MYTEAM' + assert project.objects['8'].buildSettings['DEVELOPMENT_TEAM'] == 'MYTEAM' - self.assertEqual(project.objects['5'].buildSettings['PROVISIONING_PROFILE'], '0x0x0x0x0') - self.assertEqual(project.objects['6'].buildSettings['PROVISIONING_PROFILE'], '0x0x0x0x0') - self.assertEqual(project.objects['7'].buildSettings['PROVISIONING_PROFILE'], '0x0x0x0x0') - self.assertEqual(project.objects['8'].buildSettings['PROVISIONING_PROFILE'], '0x0x0x0x0') + assert project.objects['5'].buildSettings['PROVISIONING_PROFILE'] == '0x0x0x0x0' + assert project.objects['6'].buildSettings['PROVISIONING_PROFILE'] == '0x0x0x0x0' + assert project.objects['7'].buildSettings['PROVISIONING_PROFILE'] == '0x0x0x0x0' + assert project.objects['8'].buildSettings['PROVISIONING_PROFILE'] == '0x0x0x0x0' - self.assertEqual(project.objects['5'].buildSettings['PROVISIONING_PROFILE_SPECIFIER'], 'Provisioning name') - self.assertEqual(project.objects['6'].buildSettings['PROVISIONING_PROFILE_SPECIFIER'], 'Provisioning name') - self.assertEqual(project.objects['7'].buildSettings['PROVISIONING_PROFILE_SPECIFIER'], 'Provisioning name') - self.assertEqual(project.objects['8'].buildSettings['PROVISIONING_PROFILE_SPECIFIER'], 'Provisioning name') + assert project.objects['5'].buildSettings['PROVISIONING_PROFILE_SPECIFIER'] == 'Provisioning name' + assert project.objects['6'].buildSettings['PROVISIONING_PROFILE_SPECIFIER'] == 'Provisioning name' + assert project.objects['7'].buildSettings['PROVISIONING_PROFILE_SPECIFIER'] == 'Provisioning name' + assert project.objects['8'].buildSettings['PROVISIONING_PROFILE_SPECIFIER'] == 'Provisioning name' def testAddCodeSignOneTargetAllConfigurations(self): project = XcodeProject(self.obj) project.add_code_sign('iPhone Distribution', 'MYTEAM', '0x0x0x0x0', 'Provisioning name', target_name='app') - self.assertEqual(project.objects['0'].attributes.TargetAttributes[u'1'].ProvisioningStyle, - PBXProvisioningTypes.MANUAL) - self.assertIsNone(project.objects['0'].attributes.TargetAttributes[u'2']) + assert project.objects['0'].attributes.TargetAttributes[u'1'].ProvisioningStyle == \ + PBXProvisioningTypes.MANUAL + assert project.objects['0'].attributes.TargetAttributes[u'2'] is None - self.assertIsNone(project.objects['7']['buildSettings']) - self.assertIsNone(project.objects['8']['buildSettings']) + assert project.objects['7']['buildSettings'] is None + assert project.objects['8']['buildSettings'] is None - self.assertEqual(project.objects['5'].buildSettings['CODE_SIGN_IDENTITY[sdk=iphoneos*]'], 'iPhone Distribution') - self.assertEqual(project.objects['6'].buildSettings['CODE_SIGN_IDENTITY[sdk=iphoneos*]'], 'iPhone Distribution') + assert project.objects['5'].buildSettings['CODE_SIGN_IDENTITY[sdk=iphoneos*]'] == 'iPhone Distribution' + assert project.objects['6'].buildSettings['CODE_SIGN_IDENTITY[sdk=iphoneos*]'] == 'iPhone Distribution' - self.assertEqual(project.objects['5'].buildSettings['DEVELOPMENT_TEAM'], 'MYTEAM') - self.assertEqual(project.objects['6'].buildSettings['DEVELOPMENT_TEAM'], 'MYTEAM') + assert project.objects['5'].buildSettings['DEVELOPMENT_TEAM'] == 'MYTEAM' + assert project.objects['6'].buildSettings['DEVELOPMENT_TEAM'] == 'MYTEAM' - self.assertEqual(project.objects['5'].buildSettings['PROVISIONING_PROFILE'], '0x0x0x0x0') - self.assertEqual(project.objects['6'].buildSettings['PROVISIONING_PROFILE'], '0x0x0x0x0') + assert project.objects['5'].buildSettings['PROVISIONING_PROFILE'] == '0x0x0x0x0' + assert project.objects['6'].buildSettings['PROVISIONING_PROFILE'] == '0x0x0x0x0' - self.assertEqual(project.objects['5'].buildSettings['PROVISIONING_PROFILE_SPECIFIER'], 'Provisioning name') - self.assertEqual(project.objects['6'].buildSettings['PROVISIONING_PROFILE_SPECIFIER'], 'Provisioning name') + assert project.objects['5'].buildSettings['PROVISIONING_PROFILE_SPECIFIER'] == 'Provisioning name' + assert project.objects['6'].buildSettings['PROVISIONING_PROFILE_SPECIFIER'] == 'Provisioning name' def testAddCodeSignAllTargetOneConfigurations(self): project = XcodeProject(self.obj) project.add_code_sign('iPhone Distribution', 'MYTEAM', '0x0x0x0x0', 'Provisioning name', configuration_name='Release') - self.assertEqual(project.objects['0'].attributes.TargetAttributes[u'1'].ProvisioningStyle, PBXProvisioningTypes.MANUAL) - self.assertEqual(project.objects['0'].attributes.TargetAttributes[u'2'].ProvisioningStyle, - PBXProvisioningTypes.MANUAL) + assert project.objects['0'].attributes.TargetAttributes[u'1'].ProvisioningStyle == PBXProvisioningTypes.MANUAL + assert project.objects['0'].attributes.TargetAttributes[u'2'].ProvisioningStyle == \ + PBXProvisioningTypes.MANUAL - self.assertIsNone(project.objects['6']['buildSettings']) - self.assertIsNone(project.objects['8']['buildSettings']) - self.assertEqual(project.objects['5'].buildSettings['CODE_SIGN_IDENTITY[sdk=iphoneos*]'], 'iPhone Distribution') - self.assertEqual(project.objects['7'].buildSettings['CODE_SIGN_IDENTITY[sdk=iphoneos*]'], 'iPhone Distribution') + assert project.objects['6']['buildSettings'] is None + assert project.objects['8']['buildSettings'] is None + assert project.objects['5'].buildSettings['CODE_SIGN_IDENTITY[sdk=iphoneos*]'] == 'iPhone Distribution' + assert project.objects['7'].buildSettings['CODE_SIGN_IDENTITY[sdk=iphoneos*]'] == 'iPhone Distribution' - self.assertEqual(project.objects['5'].buildSettings['DEVELOPMENT_TEAM'], 'MYTEAM') - self.assertEqual(project.objects['7'].buildSettings['DEVELOPMENT_TEAM'], 'MYTEAM') + assert project.objects['5'].buildSettings['DEVELOPMENT_TEAM'] == 'MYTEAM' + assert project.objects['7'].buildSettings['DEVELOPMENT_TEAM'] == 'MYTEAM' - self.assertEqual(project.objects['5'].buildSettings['PROVISIONING_PROFILE'], '0x0x0x0x0') - self.assertEqual(project.objects['7'].buildSettings['PROVISIONING_PROFILE'], '0x0x0x0x0') + assert project.objects['5'].buildSettings['PROVISIONING_PROFILE'] == '0x0x0x0x0' + assert project.objects['7'].buildSettings['PROVISIONING_PROFILE'] == '0x0x0x0x0' - self.assertEqual(project.objects['5'].buildSettings['PROVISIONING_PROFILE_SPECIFIER'], 'Provisioning name') - self.assertEqual(project.objects['7'].buildSettings['PROVISIONING_PROFILE_SPECIFIER'], 'Provisioning name') + assert project.objects['5'].buildSettings['PROVISIONING_PROFILE_SPECIFIER'] == 'Provisioning name' + assert project.objects['7'].buildSettings['PROVISIONING_PROFILE_SPECIFIER'] == 'Provisioning name' diff --git a/tests/pbxextensions/TestProjectGroups.py b/tests/pbxextensions/TestProjectGroups.py index 7cd37a0a..a936fd22 100644 --- a/tests/pbxextensions/TestProjectGroups.py +++ b/tests/pbxextensions/TestProjectGroups.py @@ -2,6 +2,7 @@ from pbxproj import XcodeProject from pbxproj.pbxextensions import ProjectGroups +import pytest class ProjectGroupsTest(unittest.TestCase): @@ -30,88 +31,88 @@ def setUp(self): } def testInit(self): - with self.assertRaisesRegex(EnvironmentError, '^This class cannot be instantiated directly'): + with pytest.raises(EnvironmentError, match='^This class cannot be instantiated directly'): ProjectGroups() def testGetGroupsByNameNoParent(self): project = XcodeProject(self.obj) groups = project.get_groups_by_name('app') - self.assertIn(project.objects['2'], groups) - self.assertIn(project.objects['3'], groups) - self.assertIn(project.objects['5'], groups) - self.assertIn(project.objects['6'], groups) + assert project.objects['2'] in groups + assert project.objects['3'] in groups + assert project.objects['5'] in groups + assert project.objects['6'] in groups def testGetGroupsByNameFromParent(self): project = XcodeProject(self.obj) groups = project.get_groups_by_name('app', parent=project.objects['1']) - self.assertIn(project.objects['2'], groups) - self.assertIn(project.objects['3'], groups) - self.assertNotIn(project.objects['5'], groups) - self.assertNotIn(project.objects['6'], groups) + assert project.objects['2'] in groups + assert project.objects['3'] in groups + assert project.objects['5'] not in groups + assert project.objects['6'] not in groups def testGetGroupsByPathNoParent(self): project = XcodeProject(self.obj) groups = project.get_groups_by_path('..') - self.assertIn(project.objects['2p'], groups) - self.assertIn(project.objects['3p'], groups) - self.assertIn(project.objects['5p'], groups) - self.assertIn(project.objects['6p'], groups) + assert project.objects['2p'] in groups + assert project.objects['3p'] in groups + assert project.objects['5p'] in groups + assert project.objects['6p'] in groups def testGetGroupsByPathFromParent(self): project = XcodeProject(self.obj) groups = project.get_groups_by_path('..', parent=project.objects['1p']) - self.assertIn(project.objects['2p'], groups) - self.assertIn(project.objects['3p'], groups) - self.assertNotIn(project.objects['5p'], groups) - self.assertNotIn(project.objects['6p'], groups) + assert project.objects['2p'] in groups + assert project.objects['3p'] in groups + assert project.objects['5p'] not in groups + assert project.objects['6p'] not in groups def testAddGroupNoParent(self): project = XcodeProject(self.obj) group = project.add_group('my_group') - self.assertTrue(project.objects['root'].has_child(group)) + assert project.objects['root'].has_child(group) def testAddGroupToParent(self): project = XcodeProject(self.obj) group = project.add_group('my_group', parent=project.objects['1']) - self.assertTrue(project.objects['1'].has_child(group)) + assert project.objects['1'].has_child(group) def testRemoveByIdNotFound(self): project = XcodeProject(self.obj) - self.assertFalse(project.remove_group_by_id('xxx')) + assert not project.remove_group_by_id('xxx') def testRemoveByIdRecursive(self): project = XcodeProject(self.obj) group1 = project.objects['1'] result = project.remove_group_by_id('1', recursive=True) - self.assertTrue(result) - self.assertFalse(project.objects['root'].has_child(group1)) - self.assertIsNone(project.objects['1']) - self.assertIsNone(project.objects['2']) - self.assertIsNone(project.objects['3']) + assert result + assert not project.objects['root'].has_child(group1) + assert project.objects['1'] is None + assert project.objects['2'] is None + assert project.objects['3'] is None def testRemoveByIdNonRecursive(self): project = XcodeProject(self.obj) group = project.objects['1'] result = project.remove_group_by_id('1', recursive=False) - self.assertTrue(result) - self.assertFalse(project.objects['root'].has_child(group)) - self.assertIsNone(project.objects['1']) - self.assertIsNotNone(project.objects['2']) - self.assertIsNotNone(project.objects['3']) + assert result + assert not project.objects['root'].has_child(group) + assert project.objects['1'] is None + assert project.objects['2'] is not None + assert project.objects['3'] is not None def testRemoveByNameNotFound(self): project = XcodeProject(self.obj) - self.assertFalse(project.remove_group_by_name('xxx')) + assert not project.remove_group_by_name('xxx') def testRemoveByNameRecursive(self): project = XcodeProject(self.obj) @@ -119,15 +120,15 @@ def testRemoveByNameRecursive(self): group1p = project.objects['1p'] result = project.remove_group_by_name('root', recursive=True) - self.assertTrue(result) - self.assertFalse(project.objects['root'].has_child(group1)) - self.assertFalse(project.objects['root'].has_child(group1p)) - self.assertIsNone(project.objects['1']) - self.assertIsNone(project.objects['2']) - self.assertIsNone(project.objects['3']) - self.assertIsNone(project.objects['1p']) - self.assertIsNone(project.objects['2p']) - self.assertIsNone(project.objects['3p']) + assert result + assert not project.objects['root'].has_child(group1) + assert not project.objects['root'].has_child(group1p) + assert project.objects['1'] is None + assert project.objects['2'] is None + assert project.objects['3'] is None + assert project.objects['1p'] is None + assert project.objects['2p'] is None + assert project.objects['3p'] is None def testRemoveByNameNonRecursive(self): project = XcodeProject(self.obj) @@ -135,63 +136,63 @@ def testRemoveByNameNonRecursive(self): group1p = project.objects['1p'] result = project.remove_group_by_name('root', recursive=False) - self.assertTrue(result) - self.assertFalse(project.objects['root'].has_child(group1)) - self.assertFalse(project.objects['root'].has_child(group1p)) - self.assertIsNone(project.objects['1']) - self.assertIsNotNone(project.objects['2']) - self.assertIsNotNone(project.objects['3']) - self.assertIsNone(project.objects['1p']) - self.assertIsNotNone(project.objects['2p']) - self.assertIsNotNone(project.objects['3p']) + assert result + assert not project.objects['root'].has_child(group1) + assert not project.objects['root'].has_child(group1p) + assert project.objects['1'] is None + assert project.objects['2'] is not None + assert project.objects['3'] is not None + assert project.objects['1p'] is None + assert project.objects['2p'] is not None + assert project.objects['3p'] is not None def testRemoveByIdRecursivelyWithFiles(self): project = XcodeProject(self.obj) result = project.remove_group_by_id('a') - self.assertTrue(result) - self.assertIsNone(project.objects['a']) - self.assertIsNone(project.objects['b']) - self.assertIsNone(project.objects['c']) + assert result + assert project.objects['a'] is None + assert project.objects['b'] is None + assert project.objects['c'] is None def testRemoveBrokenGroups(self): project = XcodeProject(self.obj) result = project.remove_group_by_id('broken') - self.assertFalse(result) + assert not result def testRemoveBrokenGroupsByName(self): project = XcodeProject(self.obj) result = project.remove_group_by_name('broken') - self.assertFalse(result) + assert not result def testGetOrCreateGroupNoName(self): project = XcodeProject(self.obj) group = project.get_or_create_group(None) - self.assertIsNone(group) + assert group is None def testGetOrCreateGroupNotFound(self): project = XcodeProject(self.obj) group = project.get_or_create_group('whatever') - self.assertIsNotNone(group) - self.assertNotIn(group.get_id(), self.obj['objects']) + assert group is not None + assert group.get_id() not in self.obj['objects'] def testGetOrCreateGroupFound(self): project = XcodeProject(self.obj) group = project.get_or_create_group('root') - self.assertIsNotNone(group) - self.assertIn(group.get_id(), self.obj['objects']) + assert group is not None + assert group.get_id() in self.obj['objects'] def testGetParentGroupCreateDefault(self): project = XcodeProject({'objects': {}}) group = project._get_parent_group(None) - self.assertIsNotNone(group) - self.assertEqual(project.objects[group.get_id()], group) + assert group is not None + assert project.objects[group.get_id()] == group def testGetParentGroupFromMainGroup(self): project = XcodeProject( @@ -204,11 +205,11 @@ def testGetParentGroupFromMainGroup(self): }) group = project._get_parent_group(None) - self.assertIsNotNone(group) - self.assertEqual(project.objects[project.objects['project'].mainGroup], group) + assert group is not None + assert project.objects[project.objects['project'].mainGroup] == group def testGetParentGroupWithID(self): project = XcodeProject(self.obj) parent = project._get_parent_group('5p') - self.assertEqual(parent, project.objects['5p']) + assert parent == project.objects['5p'] diff --git a/tests/pbxsections/TestPBXBuildFile.py b/tests/pbxsections/TestPBXBuildFile.py index cb5466a0..9b3d52d6 100644 --- a/tests/pbxsections/TestPBXBuildFile.py +++ b/tests/pbxsections/TestPBXBuildFile.py @@ -10,7 +10,7 @@ def testPrintOnSingleLine(self): obj = {"isa": "PBXBuildFile", "name": "something"} dobj = PBXBuildFile().parse(obj) - self.assertEqual(dobj.__repr__(), "{isa = PBXBuildFile; name = something; }") + assert dobj.__repr__() == "{isa = PBXBuildFile; name = something; }" def testGetComment(self): obj = { @@ -22,45 +22,45 @@ def testGetComment(self): } dobj = XcodeProject().parse(obj) - self.assertEqual(dobj.objects['1']._get_comment(), 'real name in X') + assert dobj.objects['1']._get_comment() == 'real name in X' def testGetAttributesWithoutSettings(self): dobj = PBXBuildFile.create(PBXGenericObject()) attributes = dobj.get_attributes() - self.assertIsNone(attributes) + assert attributes is None def testGetAttributesWithoutAttributes(self): dobj = PBXBuildFile.create(PBXGenericObject(), compiler_flags='x') attributes = dobj.get_attributes() - self.assertIsNone(attributes) + assert attributes is None def testGetAttributesWithAttributes(self): dobj = PBXBuildFile.create(PBXGenericObject(), attributes='x') attributes = dobj.get_attributes() - self.assertIsNotNone(attributes) - self.assertEqual(attributes, ['x']) + assert attributes is not None + assert attributes == ['x'] def testGetCompilerFlagsWithoutSettings(self): dobj = PBXBuildFile.create(PBXGenericObject()) - self.assertIsNone(dobj.get_compiler_flags()) + assert dobj.get_compiler_flags() is None def testGetCompilerFlagsWithoutFlags(self): dobj = PBXBuildFile.create(PBXGenericObject(), attributes='x') - self.assertIsNone(dobj.get_compiler_flags()) + assert dobj.get_compiler_flags() is None def testGetCompilerFlagsWithFlags(self): dobj = PBXBuildFile.create(PBXGenericObject(), compiler_flags=['Weak', '-fno-arc']) - self.assertIsNotNone(dobj.get_compiler_flags()) - self.assertEqual(dobj.get_compiler_flags(), 'Weak -fno-arc') + assert dobj.get_compiler_flags() is not None + assert dobj.get_compiler_flags() == 'Weak -fno-arc' def testGetCommentForNonExistentRef(self): obj = { @@ -71,97 +71,97 @@ def testGetCommentForNonExistentRef(self): } dobj = XcodeProject().parse(obj) - self.assertEqual(dobj.objects['FDDF6A571C68E5B100D7A645']._get_comment(), '(null) in X') + assert dobj.objects['FDDF6A571C68E5B100D7A645']._get_comment() == '(null) in X' def testAddAttributesWithoutSettings(self): dobj = PBXBuildFile.create(PBXGenericObject()) dobj.add_attributes('Weak') - self.assertIsNotNone(dobj.settings.ATTRIBUTES) - self.assertEqual(dobj.settings.ATTRIBUTES, ['Weak']) + assert dobj.settings.ATTRIBUTES is not None + assert dobj.settings.ATTRIBUTES == ['Weak'] def testAddAttributeList(self): dobj = PBXBuildFile.create(PBXGenericObject()) dobj.add_attributes(['Weak', 'Custom']) - self.assertIsNotNone(dobj.settings.ATTRIBUTES) - self.assertEqual(dobj.settings.ATTRIBUTES, ['Weak', 'Custom']) + assert dobj.settings.ATTRIBUTES is not None + assert dobj.settings.ATTRIBUTES == ['Weak', 'Custom'] def testAddAttributesWithoutAttributes(self): dobj = PBXBuildFile.create(PBXGenericObject(), compiler_flags='x') dobj.add_attributes('Weak') - self.assertIsNotNone(dobj.settings.ATTRIBUTES) - self.assertEqual(dobj.settings.ATTRIBUTES, ['Weak']) + assert dobj.settings.ATTRIBUTES is not None + assert dobj.settings.ATTRIBUTES == ['Weak'] def testAddAttributesWithAttributes(self): dobj = PBXBuildFile.create(PBXGenericObject(), attributes='x') dobj.add_attributes('Weak') - self.assertIsNotNone(dobj.settings.ATTRIBUTES) - self.assertEqual(dobj.settings.ATTRIBUTES, ['x', 'Weak']) + assert dobj.settings.ATTRIBUTES is not None + assert dobj.settings.ATTRIBUTES == ['x', 'Weak'] def testRemoveAttributesWithoutSettings(self): dobj = PBXBuildFile.create(PBXGenericObject()) dobj.remove_attributes('Weak') - self.assertIsNone(dobj['settings']) + assert dobj['settings'] is None def testRemoveAttributeList(self): dobj = PBXBuildFile.create(PBXGenericObject(), attributes=['Weak', 'Custom']) dobj.remove_attributes(['Weak', 'Custom']) - self.assertIsNone(dobj['settings']) + assert dobj['settings'] is None def testRemoveAttributesWithSettings(self): dobj = PBXBuildFile.create(PBXGenericObject(), attributes=['Weak']) dobj.remove_attributes('Weak') - self.assertIsNone(dobj['settings']) + assert dobj['settings'] is None def testAddCompilerFlagWithoutSettings(self): dobj = PBXBuildFile.create(PBXGenericObject()) dobj.add_compiler_flags(['Weak', '-fno-arc']) - self.assertIsNotNone(dobj.settings.COMPILER_FLAGS) - self.assertEqual(dobj.settings.COMPILER_FLAGS, 'Weak -fno-arc') + assert dobj.settings.COMPILER_FLAGS is not None + assert dobj.settings.COMPILER_FLAGS == 'Weak -fno-arc' def testAddCompilerFlagWithFlags(self): dobj = PBXBuildFile.create(PBXGenericObject(), compiler_flags=['Weak', '-fno-arc']) dobj.add_compiler_flags('x') - self.assertIsNotNone(dobj.settings.COMPILER_FLAGS) - self.assertEqual(dobj.settings.COMPILER_FLAGS, 'Weak -fno-arc x') + assert dobj.settings.COMPILER_FLAGS is not None + assert dobj.settings.COMPILER_FLAGS == 'Weak -fno-arc x' def testRemoveCompilerFlagsWithoutSettings(self): dobj = PBXBuildFile.create(PBXGenericObject()) dobj.remove_compiler_flags('Weak') - self.assertIsNone(dobj['settings']) + assert dobj['settings'] is None def testRemoveCompilerFlagsWithSettings(self): dobj = PBXBuildFile.create(PBXGenericObject(), compiler_flags='Weak') dobj.remove_compiler_flags('Weak') - self.assertIsNone(dobj['settings']) + assert dobj['settings'] is None def testRemoveCompilerFlagsList(self): dobj = PBXBuildFile.create(PBXGenericObject(), compiler_flags=['Weak', 'Custom', 'Another']) dobj.remove_compiler_flags(['Weak', 'Custom']) - self.assertIsNotNone(dobj['settings']) - self.assertEqual(dobj['settings'].__repr__(), PBXGenericObject().parse({'COMPILER_FLAGS': 'Another'}).__repr__()) + assert dobj['settings'] is not None + assert dobj['settings'].__repr__() == PBXGenericObject().parse({'COMPILER_FLAGS': 'Another'}).__repr__() def testRemoveNonRecursive(self): obj = { @@ -175,8 +175,8 @@ def testRemoveNonRecursive(self): project = PBXGenericObject().parse(obj) project.objects['1'].remove(recursive=False) - self.assertIsNone(project.objects['1']) - self.assertIsNotNone(project.objects['2']) + assert project.objects['1'] is None + assert project.objects['2'] is not None def testGetCommentOfProduct(self): obj = { @@ -188,28 +188,28 @@ def testGetCommentOfProduct(self): } dobj = XcodeProject().parse(obj) - self.assertEqual(dobj.objects['1']._get_comment(), 'real name in X') + assert dobj.objects['1']._get_comment() == 'real name in X' def testPrintFile(self): obj = {"isa": "PBXBuildFile", "fileRef": "X" } dobj = PBXBuildFile().parse(obj) - self.assertEqual(dobj.__repr__(), "{isa = PBXBuildFile; fileRef = X; }") + assert dobj.__repr__() == "{isa = PBXBuildFile; fileRef = X; }" def testPrintProduct(self): obj = {"isa": "PBXBuildFile", "productRef": "X" } dobj = PBXBuildFile().parse(obj) - self.assertEqual(dobj.__repr__(), "{isa = PBXBuildFile; productRef = X; }") + assert dobj.__repr__() == "{isa = PBXBuildFile; productRef = X; }" def testIsFile(self): obj = PBXGenericObject().parse({"_id": "1" }) dobj = PBXBuildFile.create(obj) - self.assertTrue(hasattr(dobj, "fileRef")) + assert hasattr(dobj, "fileRef") def testIsProduct(self): obj = PBXGenericObject().parse({"_id": "1" }) dobj = PBXBuildFile.create(obj, is_product=True) - self.assertTrue(hasattr(dobj, "productRef")) + assert hasattr(dobj, "productRef") diff --git a/tests/pbxsections/TestPBXContainerItemProxy.py b/tests/pbxsections/TestPBXContainerItemProxy.py index dccce139..ce00229f 100644 --- a/tests/pbxsections/TestPBXContainerItemProxy.py +++ b/tests/pbxsections/TestPBXContainerItemProxy.py @@ -6,4 +6,4 @@ class PBXContainerItemProxyTest(unittest.TestCase): def testGetComment(self): obj = PBXContainerItemProxy() - self.assertEqual(obj._get_comment(), u'PBXContainerItemProxy') + assert obj._get_comment() == u'PBXContainerItemProxy' diff --git a/tests/pbxsections/TestPBXCopyFilesBuildPhase.py b/tests/pbxsections/TestPBXCopyFilesBuildPhase.py index a683cf5c..bc0fe68b 100644 --- a/tests/pbxsections/TestPBXCopyFilesBuildPhase.py +++ b/tests/pbxsections/TestPBXCopyFilesBuildPhase.py @@ -6,9 +6,9 @@ class PBXCopyFilesBuildPhaseTest(unittest.TestCase): def testGetComment(self): phase = PBXCopyFilesBuildPhase() - self.assertEqual(phase._get_comment(), "CopyFiles") + assert phase._get_comment() == "CopyFiles" def testGetCommentFromParent(self): phase = PBXCopyFilesBuildPhase() phase.name = "copy" - self.assertEqual(phase._get_comment(), "copy") + assert phase._get_comment() == "copy" diff --git a/tests/pbxsections/TestPBXFileReference.py b/tests/pbxsections/TestPBXFileReference.py index e70cdd14..e33030c6 100644 --- a/tests/pbxsections/TestPBXFileReference.py +++ b/tests/pbxsections/TestPBXFileReference.py @@ -8,23 +8,23 @@ def testPrintOnSingleLine(self): obj = {"isa": "PBXFileReference", "name": "something"} dobj = PBXFileReference().parse(obj) - self.assertEqual(dobj.__repr__(), "{isa = PBXFileReference; name = something; }") + assert dobj.__repr__() == "{isa = PBXFileReference; name = something; }" def testSetLastKnownType(self): dobj = PBXFileReference.create("path") dobj.set_last_known_file_type('something') - self.assertEqual(dobj.lastKnownFileType, "something") - self.assertIsNone(dobj['explicitFileType']) + assert dobj.lastKnownFileType == "something" + assert dobj['explicitFileType'] is None def testSetExplicityFileType(self): dobj = PBXFileReference.create("path") dobj.set_explicit_file_type('something') - self.assertEqual(dobj.explicitFileType, "something") - self.assertIsNone(dobj['lastKnownFileType']) + assert dobj.explicitFileType == "something" + assert dobj['lastKnownFileType'] is None def testSetLastTypeRemovesExplicit(self): dobj = PBXFileReference.create("path") @@ -32,8 +32,8 @@ def testSetLastTypeRemovesExplicit(self): dobj.set_explicit_file_type('something') dobj.set_last_known_file_type('something') - self.assertEqual(dobj.lastKnownFileType, "something") - self.assertIsNone(dobj['explicitFileType']) + assert dobj.lastKnownFileType == "something" + assert dobj['explicitFileType'] is None def testSetExplicitRemovesLastType(self): dobj = PBXFileReference.create("path") @@ -41,5 +41,5 @@ def testSetExplicitRemovesLastType(self): dobj.set_last_known_file_type('something') dobj.set_explicit_file_type('something') - self.assertEqual(dobj.explicitFileType, "something") - self.assertIsNone(dobj['lastKnownFileType']) + assert dobj.explicitFileType == "something" + assert dobj['lastKnownFileType'] is None diff --git a/tests/pbxsections/TestPBXFrameworksBuildPhase.py b/tests/pbxsections/TestPBXFrameworksBuildPhase.py index dd920c71..982ceb88 100644 --- a/tests/pbxsections/TestPBXFrameworksBuildPhase.py +++ b/tests/pbxsections/TestPBXFrameworksBuildPhase.py @@ -6,4 +6,4 @@ class PBXFrameworksBuildPhaseTest(unittest.TestCase): def testGetComment(self): obj = PBXFrameworksBuildPhase() - self.assertEqual(obj._get_comment(), u'Frameworks') + assert obj._get_comment() == u'Frameworks' diff --git a/tests/pbxsections/TestPBXGenericBuildPhase.py b/tests/pbxsections/TestPBXGenericBuildPhase.py index 8f6f9bd6..5a35e9e9 100644 --- a/tests/pbxsections/TestPBXGenericBuildPhase.py +++ b/tests/pbxsections/TestPBXGenericBuildPhase.py @@ -8,8 +8,8 @@ def testAddBuildFile(self): build_phase = PBXGenericBuildPhase.create(name="build_phase") result = build_phase.add_build_file(PBXGenericObject().parse({})) - self.assertFalse(result) - self.assertListEqual(build_phase.files, []) + assert not result + assert build_phase.files == [] def testRemoveBuildFileFailed(self): build_phase = PBXGenericBuildPhase.create(name="build_phase") @@ -17,4 +17,4 @@ def testRemoveBuildFileFailed(self): result = build_phase.remove_build_file(None) - self.assertFalse(result) \ No newline at end of file + assert not result \ No newline at end of file diff --git a/tests/pbxsections/TestPBXGenericTarget.py b/tests/pbxsections/TestPBXGenericTarget.py index d08e46de..7c139879 100644 --- a/tests/pbxsections/TestPBXGenericTarget.py +++ b/tests/pbxsections/TestPBXGenericTarget.py @@ -14,7 +14,7 @@ def testGetBuildPhase(self): build_phases = project.objects['1'].get_or_create_build_phase("PBXGenericBuildPhase") - self.assertListEqual(build_phases, [project.objects["2"]]) + assert build_phases == [project.objects["2"]] def testRemoveBuildPhaseFailed(self): project = XcodeProject({ @@ -26,4 +26,4 @@ def testRemoveBuildPhaseFailed(self): result = project.objects['1'].remove_build_phase(None) - self.assertFalse(result) + assert not result diff --git a/tests/pbxsections/TestPBXGroup.py b/tests/pbxsections/TestPBXGroup.py index 5a4a5f00..77194a07 100644 --- a/tests/pbxsections/TestPBXGroup.py +++ b/tests/pbxsections/TestPBXGroup.py @@ -28,67 +28,67 @@ def setUp(self): def testCreateWithoutName(self): group = PBXGroup.create('folder_name') - self.assertFalse(u'name' in group) - self.assertEqual(group.path, 'folder_name') + assert not (u'name' in group) + assert group.path == 'folder_name' def testCreateWithName(self): group = PBXGroup.create('folder_name', 'Friendly Name') - self.assertTrue(u'name' in group) - self.assertEqual(group.path, 'folder_name') - self.assertEqual(group.name, 'Friendly Name') + assert u'name' in group + assert group.path == 'folder_name' + assert group.name == 'Friendly Name' def testGetNameWithoutName(self): group = PBXGroup.create('folder_name') - self.assertEqual(group.get_name(), 'folder_name') + assert group.get_name() == 'folder_name' def testGetNameWithName(self): group = PBXGroup.create('folder_name', 'Friendly Name') - self.assertEqual(group.get_name(), 'Friendly Name') + assert group.get_name() == 'Friendly Name' def testHasChild(self): group = PBXGroup.create('folder_name', children=['child1', 'child2']) - self.assertTrue(group.has_child('child1')) - self.assertTrue(group.has_child('child2')) - self.assertFalse(group.has_child('child3')) + assert group.has_child('child1') + assert group.has_child('child2') + assert not group.has_child('child3') def testHasChildIncomplete(self): group = PBXGroup().parse({'name': 'group'}) - self.assertFalse(group.has_child('child1')) + assert not group.has_child('child1') def testAddInvalidChild(self): group = PBXGroup().parse({'name': 'group'}) invalid_group = PBXGenericObject().parse({'_id': "not-a-group"}) group.add_child(invalid_group) - self.assertFalse(group.has_child(invalid_group)) + assert not group.has_child(invalid_group) def testRemoveGroupRecusively(self): objs = objects().parse(self.obj) objs["1"].remove() - self.assertIsNone(objs["1"]) - self.assertIsNone(objs["2"]) - self.assertIsNone(objs["3"]) - self.assertIsNone(objs["3a"]) - self.assertIsNone(objs["4"]) - self.assertIsNone(objs["5"]) - self.assertIsNone(objs["5a"]) - self.assertIsNone(objs["6"]) - self.assertIsNone(objs["6a"]) - self.assertEqual(objs["bp"].files, []) - self.assertEqual(objs["z1"].children, []) + assert objs["1"] is None + assert objs["2"] is None + assert objs["3"] is None + assert objs["3a"] is None + assert objs["4"] is None + assert objs["5"] is None + assert objs["5a"] is None + assert objs["6"] is None + assert objs["6a"] is None + assert objs["bp"].files == [] + assert objs["z1"].children == [] def testRemoveGroupNonRecusively(self): objs = objects().parse(self.obj) objs["1"].remove(recursive=False) - self.assertIsNone(objs["1"]) - self.assertIsNotNone(objs["2"]) - self.assertIsNotNone(objs["3"]) - self.assertIsNotNone(objs["3a"]) - self.assertIsNotNone(objs["4"]) - self.assertIsNotNone(objs["5"]) - self.assertIsNotNone(objs["5a"]) - self.assertIsNotNone(objs["6"]) - self.assertIsNotNone(objs["6a"]) - self.assertNotEqual(objs["bp"].files, []) - self.assertNotEqual(objs["z1"].children, []) + assert objs["1"] is None + assert objs["2"] is not None + assert objs["3"] is not None + assert objs["3a"] is not None + assert objs["4"] is not None + assert objs["5"] is not None + assert objs["5a"] is not None + assert objs["6"] is not None + assert objs["6a"] is not None + assert objs["bp"].files != [] + assert objs["z1"].children != [] diff --git a/tests/pbxsections/TestPBXHeadersBuildPhase.py b/tests/pbxsections/TestPBXHeadersBuildPhase.py index 60ae9c0d..b25a7247 100644 --- a/tests/pbxsections/TestPBXHeadersBuildPhase.py +++ b/tests/pbxsections/TestPBXHeadersBuildPhase.py @@ -6,4 +6,4 @@ class PBXHeadersBuildPhaseTest(unittest.TestCase): def testGetComment(self): obj = PBXHeadersBuildPhase() - self.assertEqual(obj._get_comment(), u'Headers') + assert obj._get_comment() == u'Headers' diff --git a/tests/pbxsections/TestPBXProject.py b/tests/pbxsections/TestPBXProject.py index 870a5057..6da4d490 100644 --- a/tests/pbxsections/TestPBXProject.py +++ b/tests/pbxsections/TestPBXProject.py @@ -6,27 +6,27 @@ class PBXProjectTest(unittest.TestCase): def testGetComment(self): obj = PBXProject() - self.assertEqual(obj._get_comment(), u'Project object') + assert obj._get_comment() == u'Project object' def testSetProvisioningTypeManual(self): obj = PBXProject() target = PBXGenericObject().parse({'_id': '1'}) - self.assertIsNone(obj[u'attributes']) + assert obj[u'attributes'] is None obj.set_provisioning_style(PBXProvisioningTypes.MANUAL, target) - self.assertEqual(obj.attributes.TargetAttributes[u'1'].ProvisioningStyle, PBXProvisioningTypes.MANUAL) + assert obj.attributes.TargetAttributes[u'1'].ProvisioningStyle == PBXProvisioningTypes.MANUAL def testSetProvisioningTypeAutomatic(self): obj = PBXProject() target = PBXGenericObject().parse({'_id': '1'}) - self.assertIsNone(obj[u'attributes']) + assert obj[u'attributes'] is None obj.set_provisioning_style(PBXProvisioningTypes.AUTOMATIC, target) - self.assertEqual(obj.attributes.TargetAttributes[u'1'].ProvisioningStyle, PBXProvisioningTypes.AUTOMATIC) + assert obj.attributes.TargetAttributes[u'1'].ProvisioningStyle == PBXProvisioningTypes.AUTOMATIC def testRetainProjectReferences(self): obj = PBXProject().parse({'projectReferences': [ @@ -40,8 +40,8 @@ def testRetainProjectReferences(self): } ]}) - self.assertEqual(obj.projectReferences.__len__(), 2) - self.assertEqual(obj.projectReferences[0].ProductGroup, 'E248929D1CE31272000CB2D7') - self.assertEqual(obj.projectReferences[0].ProjectRef, 'E248929C1CE31272000CB2D7') - self.assertEqual(obj.projectReferences[1].ProductGroup, '15A8A4041834BDA200142BE0') - self.assertEqual(obj.projectReferences[1].ProjectRef, '15A8A4031834BDA200142BE0') + assert obj.projectReferences.__len__() == 2 + assert obj.projectReferences[0].ProductGroup == 'E248929D1CE31272000CB2D7' + assert obj.projectReferences[0].ProjectRef == 'E248929C1CE31272000CB2D7' + assert obj.projectReferences[1].ProductGroup == '15A8A4041834BDA200142BE0' + assert obj.projectReferences[1].ProjectRef == '15A8A4031834BDA200142BE0' diff --git a/tests/pbxsections/TestPBXResourcesBuildPhase.py b/tests/pbxsections/TestPBXResourcesBuildPhase.py index 653b3453..9870b0e3 100644 --- a/tests/pbxsections/TestPBXResourcesBuildPhase.py +++ b/tests/pbxsections/TestPBXResourcesBuildPhase.py @@ -6,4 +6,4 @@ class PBXResourcesBuildPhaseTest(unittest.TestCase): def testGetComment(self): obj = PBXResourcesBuildPhase() - self.assertEqual(obj._get_comment(), u'Resources') + assert obj._get_comment() == u'Resources' diff --git a/tests/pbxsections/TestPBXShellScriptBuildPhase.py b/tests/pbxsections/TestPBXShellScriptBuildPhase.py index 59db15f6..55a43e72 100644 --- a/tests/pbxsections/TestPBXShellScriptBuildPhase.py +++ b/tests/pbxsections/TestPBXShellScriptBuildPhase.py @@ -6,9 +6,9 @@ class PBXShellScriptBuildPhaseTest(unittest.TestCase): def testGetComment(self): obj = PBXShellScriptBuildPhase() - self.assertEqual(obj._get_comment(), u'ShellScript') + assert obj._get_comment() == u'ShellScript' def testGetCommentWithName(self): name = u'Run My Script Please' obj = PBXShellScriptBuildPhase.create(script=u'/dev/null', name=name) - self.assertEqual(obj._get_comment(), name) + assert obj._get_comment() == name diff --git a/tests/pbxsections/TestPBXSourcesBuildPhase.py b/tests/pbxsections/TestPBXSourcesBuildPhase.py index c40afa6b..49f6c565 100644 --- a/tests/pbxsections/TestPBXSourcesBuildPhase.py +++ b/tests/pbxsections/TestPBXSourcesBuildPhase.py @@ -6,4 +6,4 @@ class PBXSourcesBuildPhaseTest(unittest.TestCase): def testGetComment(self): obj = PBXSourcesBuildPhase() - self.assertEqual(obj._get_comment(), u'Sources') + assert obj._get_comment() == u'Sources' diff --git a/tests/pbxsections/TestPBXTargetDependency.py b/tests/pbxsections/TestPBXTargetDependency.py index 93a37da7..573dbdc8 100644 --- a/tests/pbxsections/TestPBXTargetDependency.py +++ b/tests/pbxsections/TestPBXTargetDependency.py @@ -6,4 +6,4 @@ class PBXTargetDependencyTest(unittest.TestCase): def testGetComment(self): obj = PBXTargetDependency() - self.assertEqual(obj._get_comment(), u'PBXTargetDependency') + assert obj._get_comment() == u'PBXTargetDependency' diff --git a/tests/pbxsections/TestXCBuildConfiguration.py b/tests/pbxsections/TestXCBuildConfiguration.py index 3859f72f..a7e12db1 100644 --- a/tests/pbxsections/TestXCBuildConfiguration.py +++ b/tests/pbxsections/TestXCBuildConfiguration.py @@ -8,80 +8,80 @@ def testAddFlagOnNewObject(self): obj = XCBuildConfiguration() obj.add_flags('flag', '-flag') - self.assertIsNotNone(obj.buildSettings) - self.assertIsNotNone(obj.buildSettings.flag) - self.assertEqual(obj.buildSettings.flag, '-flag') + assert obj.buildSettings is not None + assert obj.buildSettings.flag is not None + assert obj.buildSettings.flag == '-flag' def testAddFlagsOnNewObject(self): obj = XCBuildConfiguration() obj.add_flags('flag', ['-flag', '-another-flag']) - self.assertIsNotNone(obj.buildSettings) - self.assertIsNotNone(obj.buildSettings.flag) - self.assertListEqual(obj.buildSettings.flag, ['-flag', '-another-flag']) + assert obj.buildSettings is not None + assert obj.buildSettings.flag is not None + assert obj.buildSettings.flag == ['-flag', '-another-flag'] def testAddFlagOnSingleFlag(self): obj = {'isa': 'XCBuildConfiguration', 'buildSettings': {'flag': '-flag'}} dobj = XCBuildConfiguration().parse(obj) dobj.add_flags('flag', '-another-flag') - self.assertListEqual(dobj.buildSettings.flag, ['-flag', '-another-flag']) + assert dobj.buildSettings.flag == ['-flag', '-another-flag'] def testAddFlagOnMultipleFlags(self): obj = {'isa': 'XCBuildConfiguration', 'buildSettings': {'flag': ['-flag', '-b-flag']}} dobj = XCBuildConfiguration().parse(obj) dobj.add_flags('flag', '-another-flag') - self.assertListEqual(dobj.buildSettings.flag, ['-flag', '-b-flag', '-another-flag']) + assert dobj.buildSettings.flag == ['-flag', '-b-flag', '-another-flag'] def testAddFlagsOnSingleFlag(self): obj = {'isa': 'XCBuildConfiguration', 'buildSettings': {'flag': '-flag'}} dobj = XCBuildConfiguration().parse(obj) dobj.add_flags('flag', ['-another-flag']) - self.assertListEqual(dobj.buildSettings.flag, ['-flag', '-another-flag']) + assert dobj.buildSettings.flag == ['-flag', '-another-flag'] def testAddFlagsOnMultipleFlags(self): obj = {'isa': 'XCBuildConfiguration', 'buildSettings': {'flag': ['-flag', '-b-flag']}} dobj = XCBuildConfiguration().parse(obj) dobj.add_flags('flag', ['-another-flag']) - self.assertListEqual(dobj.buildSettings.flag, ['-flag', '-b-flag', '-another-flag']) + assert dobj.buildSettings.flag == ['-flag', '-b-flag', '-another-flag'] def testRemoveFlagOnEmpty(self): obj = {'isa': 'XCBuildConfiguration'} dobj = XCBuildConfiguration().parse(obj) dobj.remove_flags('flag', '-flag') - self.assertIsNone(dobj['buildSettings']) + assert dobj['buildSettings'] is None def testRemoveFlagNonExistent(self): obj = {'isa': 'XCBuildConfiguration', 'buildSettings': {'flag1': '-flag'}} dobj = XCBuildConfiguration().parse(obj) dobj.remove_flags('flag', '-flag') - self.assertIsNone(dobj.buildSettings['flag']) + assert dobj.buildSettings['flag'] is None def testRemoveFlagOnSingleValue(self): obj = {'isa': 'XCBuildConfiguration', 'buildSettings': {'flag': '-flag'}} dobj = XCBuildConfiguration().parse(obj) dobj.remove_flags('flag', '-flag') - self.assertIsNone(dobj.buildSettings['flag']) + assert dobj.buildSettings['flag'] is None def testRemoveFlagAllValues(self): obj = {'isa': 'XCBuildConfiguration', 'buildSettings': {'flag': '-flag'}} dobj = XCBuildConfiguration().parse(obj) dobj.remove_flags('flag', None) - self.assertIsNone(dobj.buildSettings['flag']) + assert dobj.buildSettings['flag'] is None def testRemoveFlagOnMultipleValue(self): obj = {'isa': 'XCBuildConfiguration', 'buildSettings': {'flag': ['-flag', '-b-flag']}} dobj = XCBuildConfiguration().parse(obj) dobj.remove_flags('flag', '-flag') - self.assertEqual(dobj.buildSettings.flag, '-b-flag') + assert dobj.buildSettings.flag == '-b-flag' def testAddSearchPathRecursiveUnEscaped(self): obj = {'isa': 'XCBuildConfiguration', 'buildSettings': {}} @@ -89,7 +89,7 @@ def testAddSearchPathRecursiveUnEscaped(self): dobj.add_search_paths('search', '$(SRC_ROOT)', recursive=True) - self.assertEqual(dobj.buildSettings.search, '$(SRC_ROOT)/**') + assert dobj.buildSettings.search == '$(SRC_ROOT)/**' def testAddSearchPathNonRecursiveUnEscaped(self): obj = {'isa': 'XCBuildConfiguration', 'buildSettings': {}} @@ -97,7 +97,7 @@ def testAddSearchPathNonRecursiveUnEscaped(self): dobj.add_search_paths('search', '$(SRC_ROOT)', recursive=False) - self.assertEqual(dobj.buildSettings.search, '$(SRC_ROOT)') + assert dobj.buildSettings.search == '$(SRC_ROOT)' def testAddSearchPathRecursiveEscaped(self): obj = {'isa': 'XCBuildConfiguration', 'buildSettings': {}} @@ -105,7 +105,7 @@ def testAddSearchPathRecursiveEscaped(self): dobj.add_search_paths('search', '$(SRC_ROOT)', recursive=True, escape=True) - self.assertEqual(dobj.buildSettings.search, '"$(SRC_ROOT)"/**') + assert dobj.buildSettings.search == '"$(SRC_ROOT)"/**' def testAddSearchPathNonRecursiveEscaped(self): obj = {'isa': 'XCBuildConfiguration', 'buildSettings': {}} @@ -113,7 +113,7 @@ def testAddSearchPathNonRecursiveEscaped(self): dobj.add_search_paths('search', '$(SRC_ROOT)', recursive=False, escape=True) - self.assertEqual(dobj.buildSettings.search, '"$(SRC_ROOT)"') + assert dobj.buildSettings.search == '"$(SRC_ROOT)"' def testAddSearchPathInherit(self): obj = {'isa': 'XCBuildConfiguration', 'buildSettings': {}} @@ -121,7 +121,7 @@ def testAddSearchPathInherit(self): dobj.add_search_paths('search', '$(inherited)') - self.assertEqual(dobj.buildSettings.search, '$(inherited)') + assert dobj.buildSettings.search == '$(inherited)' def testRemoveSearchPath(self): obj = {'isa': 'XCBuildConfiguration', 'buildSettings': {'search': '$(inherited)'}} @@ -129,4 +129,4 @@ def testRemoveSearchPath(self): dobj.remove_search_paths('search', '$(inherited)') - self.assertIsNone(dobj.buildSettings['search']) + assert dobj.buildSettings['search'] is None diff --git a/tests/pbxsections/TestXCConfigurationList.py b/tests/pbxsections/TestXCConfigurationList.py index 6641588d..47c2d687 100644 --- a/tests/pbxsections/TestXCConfigurationList.py +++ b/tests/pbxsections/TestXCConfigurationList.py @@ -9,7 +9,7 @@ def testGetComment(self): config = XCConfigurationList() config._get_section = lambda: ('TargetType', 'name') - self.assertEqual(config._get_comment(), 'Build configuration list for TargetType "name"') + assert config._get_comment() == 'Build configuration list for TargetType "name"' def testGetSectionOnNativeTarget(self): objs = objects(None).parse( @@ -24,7 +24,7 @@ def testGetSectionOnNativeTarget(self): } }) config = objs['2'] - self.assertEqual(config._get_comment(), 'Build configuration list for PBXNativeTarget "the-target-name"') + assert config._get_comment() == 'Build configuration list for PBXNativeTarget "the-target-name"' def testGetSectionOnLegacyTarget(self): objs = objects(None).parse( @@ -39,7 +39,7 @@ def testGetSectionOnLegacyTarget(self): } }) config = objs['2'] - self.assertEqual(config._get_comment(), 'Build configuration list for PBXLegacyTarget "the-target-name"') + assert config._get_comment() == 'Build configuration list for PBXLegacyTarget "the-target-name"' def testGetSectionOnProject(self): objs = objects(None).parse( @@ -55,4 +55,4 @@ def testGetSectionOnProject(self): } }) config = objs['2'] - self.assertEqual(config._get_comment(), 'Build configuration list for PBXProject "the-target-name"') + assert config._get_comment() == 'Build configuration list for PBXProject "the-target-name"' diff --git a/tests/pbxsections/TestXCRemoteSwiftPackageReference.py b/tests/pbxsections/TestXCRemoteSwiftPackageReference.py index f04516e5..b71822bb 100644 --- a/tests/pbxsections/TestXCRemoteSwiftPackageReference.py +++ b/tests/pbxsections/TestXCRemoteSwiftPackageReference.py @@ -5,16 +5,16 @@ class TestXCRemoteSwiftPackageReference(unittest.TestCase): def testGetComment(self): obj = XCRemoteSwiftPackageReference.create('http://myrepo.com/some-package', {}) - self.assertEqual(obj._get_comment(), 'XCRemoteSwiftPackageReference "some-package"') + assert obj._get_comment() == 'XCRemoteSwiftPackageReference "some-package"' def testGetCommentWithoutGitExtension(self): obj = XCRemoteSwiftPackageReference.create('http://myrepo.com/some-package.git', {}) - self.assertEqual(obj._get_comment(), 'XCRemoteSwiftPackageReference "some-package"') + assert obj._get_comment() == 'XCRemoteSwiftPackageReference "some-package"' def testRequirementIsNotNone(self): obj = XCRemoteSwiftPackageReference.create('http://myrepo.com/some-package', {}) - self.assertIsNotNone(obj['requirement']) + assert obj['requirement'] is not None def testRequirementIsPopulated(self): obj = XCRemoteSwiftPackageReference.create('http://myrepo.com/some-package', { "kind": "branch" }) - self.assertEqual(obj['requirement']['kind'], 'branch') + assert obj['requirement']['kind'] == 'branch' diff --git a/tests/pbxsections/TestXCSwiftPackageProductDependency.py b/tests/pbxsections/TestXCSwiftPackageProductDependency.py index 6ad51ced..c6723fd4 100644 --- a/tests/pbxsections/TestXCSwiftPackageProductDependency.py +++ b/tests/pbxsections/TestXCSwiftPackageProductDependency.py @@ -6,9 +6,9 @@ class TestXCSwiftPackageProductDependency(unittest.TestCase): def testGetComment(self): obj = PBXGenericObject() dobj = XCSwiftPackageProductDependency.create(obj, 'Some Product') - self.assertEqual(dobj._get_comment(), 'Some Product') + assert dobj._get_comment() == 'Some Product' def testPackageIsNotNone(self): obj = PBXGenericObject().parse({"_id": "1" }) dobj = XCSwiftPackageProductDependency.create(obj, 'Some Product') - self.assertIsNotNone(dobj['package']) + assert dobj['package'] is not None