Skip to content

Commit

Permalink
refactor: make the test fixtures agnostic from the invocation path (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
kronenthaler authored Aug 19, 2024
1 parent 7b35fc1 commit d17b999
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 23 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/branch-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
id: checkout

- name: Setup
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}

Expand All @@ -34,7 +34,7 @@ jobs:

- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
if: github.event_name == 'pull_request' && matrix.python == '3.x'
if: github.event_name == 'pull_request' && matrix.python == '3.x' && github.event.pull_request.head.repo.full_name != github.repository
with:
args: >
-Dsonar.projectVersion=${{ env.VERSION }}
Expand All @@ -58,7 +58,7 @@ jobs:

- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
if: github.event_name == 'push' && matrix.python == '3.x'
if: github.event_name == 'push' && matrix.python == '3.x' && github.event.pull_request.head.repo.full_name != github.repository
with:
args: >
-Dsonar.projectVersion=${{ env.VERSION }}
Expand All @@ -76,4 +76,4 @@ jobs:
-Dsonar.objc.file.suffixes=-
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
7 changes: 3 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
id: checkout
uses: actions/checkout@v4

- name: Setup
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.x'

Expand All @@ -29,4 +28,4 @@ jobs:
twine upload dist/*
env:
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
TWINE_USERNAME: kronenthaler
TWINE_USERNAME: kronenthaler
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
.PHONY: coverage coverage-term test install-dependencies

coverage: install-dependencies
cd tests; pytest --cov-report=xml --cov=../ --cov-branch
cd tests; rm -rf .coverage
pytest --cov-report=xml --cov=../ --cov-branch
rm -rf .coverage

coverage-term: install-dependencies
cd tests; pytest --cov-report=term --cov=../ --cov-branch
cd tests; rm -rf .coverage
pytest --cov-report=term --cov=../ --cov-branch
rm -rf .coverage

test:
cd tests; pytest
pytest

install-dependencies:
pip3 install -r dev-requirements.txt
3 changes: 2 additions & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[pytest]
python_files = Test*.py
pythonpath = .
pythonpath = .
testpaths = tests
14 changes: 9 additions & 5 deletions tests/TestParsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,35 +23,39 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


import os
from os.path import join
import unittest

from openstep_parser import openstep_parser as osp


class ParsingTest(unittest.TestCase):
PWD = os.path.dirname(os.path.abspath(__file__))

def testParseNestedDictionary(self):
line = '''{ a = { b = b1; }; };'''
result = osp.OpenStepDecoder()._parse_dictionary(line, 0)
assert result

def testParseFileSample1(self):
result = osp.OpenStepDecoder.ParseFromFile(open('samples/music-cube.pbxproj'))
result = osp.OpenStepDecoder.ParseFromFile(open(join(self.PWD, 'samples/music-cube.pbxproj')))
assert result

def testParseFileSample2(self):
result = osp.OpenStepDecoder.ParseFromFile(open('samples/cloud-search.pbxproj'))
result = osp.OpenStepDecoder.ParseFromFile(open(join(self.PWD, 'samples/cloud-search.pbxproj')))
assert result

def testParseFileSample3(self):
result = osp.OpenStepDecoder.ParseFromFile(open('samples/collection-view.pbxproj'))
result = osp.OpenStepDecoder.ParseFromFile(open(join(self.PWD, 'samples/collection-view.pbxproj')))
assert result

def testParseFileSample4(self):
result = osp.OpenStepDecoder.ParseFromFile(open('samples/metal-image-processing.pbxproj'))
result = osp.OpenStepDecoder.ParseFromFile(open(join(self.PWD, 'samples/metal-image-processing.pbxproj')))
assert result

def testParseFileSample5(self):
result = osp.OpenStepDecoder.ParseFromFile(open('samples/no_whitespace.pbxproj'))
result = osp.OpenStepDecoder.ParseFromFile(open(join(self.PWD, 'samples/no_whitespace.pbxproj')))
assert result

def testIgnoreWhitespacesFromBeginning(self):
Expand Down
3 changes: 0 additions & 3 deletions tests/pytest.ini

This file was deleted.

0 comments on commit d17b999

Please sign in to comment.