Skip to content

Commit

Permalink
Merge pull request #14 from LimaBD/develop
Browse files Browse the repository at this point in the history
Fix module imports
  • Loading branch information
LimaBD authored Aug 9, 2022
2 parents 0ccbe58 + e17d1a8 commit 9a5dbae
Show file tree
Hide file tree
Showing 20 changed files with 122 additions and 58 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ jobs:
npm install --location=global bats
- name: Run tests and generate coverage report
run: |
coverage run -m unittest discover ./tests/
PYTHONPATH="$(pwd):$PYTHONPATH" coverage run -m unittest discover ./tests/
coverage xml
2 changes: 1 addition & 1 deletion batspp/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
"""Version"""


__version__ = '2.1.1'
__version__ = '2.1.2'
2 changes: 1 addition & 1 deletion batspp/_ast_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


# Local modules
from _tokens import TokenData
from batspp._token import TokenData


class AST:
Expand Down
6 changes: 3 additions & 3 deletions batspp/_interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@


# Local modules
from batspp_opts import BatsppOpts
from batspp_args import BatsppArgs
from _ast_nodes import (
from batspp.batspp_opts import BatsppOpts
from batspp.batspp_args import BatsppArgs
from batspp._ast_nodes import (
TestsSuite, Test,
Assertion, AssertionType
)
Expand Down
4 changes: 2 additions & 2 deletions batspp/_lexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@


# Local modules
from _exceptions import error
from _tokens import (
from batspp._exceptions import error
from batspp._token import (
TokenData, TokenType, Token
)

Expand Down
7 changes: 3 additions & 4 deletions batspp/_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,18 @@


# Standard packages
from enum import Enum


# Installed packages
from mezcla import debug


# Local modules
from _exceptions import error
from _tokens import (
from batspp._exceptions import error
from batspp._token import (
TokenType, Token
)
from _ast_nodes import (
from batspp._ast_nodes import (
AST, TestsSuite, Test,
Assertion, AssertionType
)
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions batspp/batspp
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ from mezcla import text_utils


# Local modules
from __version__ import __version__
from batspp_opts import BatsppOpts
from batspp_args import BatsppArgs
from batspp_test import BatsppTest
from batspp.__version__ import __version__
from batspp.batspp_opts import BatsppOpts
from batspp.batspp_args import BatsppArgs
from batspp.batspp_test import BatsppTest


# Command-line labels and
Expand Down
2 changes: 1 addition & 1 deletion batspp/batspp_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


# Local modules
from _exceptions import assert_type
from batspp._exceptions import assert_type


class BatsppArgs:
Expand Down
2 changes: 1 addition & 1 deletion batspp/batspp_opts.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


# Local modules
from _exceptions import assert_type
from batspp._exceptions import assert_type


class BatsppOpts:
Expand Down
12 changes: 6 additions & 6 deletions batspp/batspp_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@


# Local modules
from _lexer import Lexer
from _parser import Parser
from _interpreter import Interpreter
from _settings import (
from batspp._lexer import Lexer
from batspp._parser import Parser
from batspp._interpreter import Interpreter
from batspp._settings import (
BATSPP_EXTENSION, BATS_EXTENSION
)
from batspp_opts import BatsppOpts
from batspp_args import BatsppArgs
from batspp.batspp_opts import BatsppOpts
from batspp.batspp_args import BatsppArgs


class BatsppTest:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"Operating System :: OS Independent",
],
scripts=['batspp/batspp'],
package_dir={"": "batspp"},
packages=['batspp'],
python_requires=">=3.8",
install_requires=required,
)
1 change: 1 addition & 0 deletions tests/run_all.bash
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
## TODO: save older runned htmlcovs.

tests=$(dirname $(realpath -s $0))
export PYTHONPATH="$tests/../:$PYTHONPATH"
echo -e "Running tests on $tests\n"
coverage run -m unittest discover $tests
coverage html --directory $tests/htmlcov
3 changes: 3 additions & 0 deletions tests/test_batspp.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
#
# Tests for batspp script
#
# This test must be runned with the command:
# $ PYTHONPATH="$(pwd):$PYTHONPATH" ./tests/test_batspp.py
#


"""Tests for batspp script"""
Expand Down
3 changes: 3 additions & 0 deletions tests/test_end_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
# output files can be updated automatically
# running: $ docs/examples/run_examples.bash
#
# This test must be runned with the command:
# $ PYTHONPATH="$(pwd):$PYTHONPATH" ./tests/test_end_usage.py
#


"""Tests for Batspp end usage"""
Expand Down
5 changes: 4 additions & 1 deletion tests/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
#
# Tests for exceptions.py module
#
# This test must be runned with the command:
# $ PYTHONPATH="$(pwd):$PYTHONPATH" ./tests/test_exceptions.py
#


"""Tests for exceptions.py module"""
Expand All @@ -19,7 +22,7 @@

# Module being tested
sys.path.insert(0, './batspp')
from _exceptions import ( # type: ignore
from batspp._exceptions import (
error, assert_type
)

Expand Down
9 changes: 6 additions & 3 deletions tests/test_interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
#
# Tests for interpreter.py module
#
# This test must be runned with the command:
# $ PYTHONPATH="$(pwd):$PYTHONPATH" ./tests/test_interpreter.py
#


"""Tests for interpreter.py module"""
Expand All @@ -19,12 +22,12 @@

# Local modules
sys.path.insert(0, './batspp')
from _tokens import TokenData # type: ignore
from _ast_nodes import ( # type: ignore
from batspp._token import TokenData
from batspp._ast_nodes import (
AssertionType, Assertion,
Test, TestsSuite
)
from _interpreter import ( # type: ignore
from batspp._interpreter import (
NodeVisitor, Interpreter
)

Expand Down
7 changes: 5 additions & 2 deletions tests/test_lexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
#
# Tests for lexer.py module
#
# This test must be runned with the command:
# $ PYTHONPATH="$(pwd):$PYTHONPATH" ./tests/test_lexer.py
#


"""Tests for lexer.py module"""
Expand All @@ -19,10 +22,10 @@

# Module being tested
sys.path.insert(0, './batspp')
from _lexer import ( # type: ignore
from batspp._lexer import (
TextLiner, Lexer
)
from _tokens import ( # type: ignore
from batspp._token import (
Token, TokenType
)

Expand Down
9 changes: 6 additions & 3 deletions tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
#
# Tests for parser.py module
#
# This test must be runned with the command:
# $ PYTHONPATH="$(pwd):$PYTHONPATH" ./tests/test_parser.py
#


"""Tests for parser.py module"""
Expand All @@ -19,9 +22,9 @@

# Local modules
sys.path.insert(0, './batspp')
from _tokens import Token, TokenType # type: ignore
from _parser import Parser # type: ignore
from _ast_nodes import ( # type: ignore
from batspp._token import Token, TokenType
from batspp._parser import Parser
from batspp._ast_nodes import (
AssertionType, Assertion,
TestsSuite, Test
)
Expand Down
94 changes: 70 additions & 24 deletions upload_dist.bash
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,83 @@
# - upload dist to PyPi
#

echo "build - checking the required tools..."

# Make sure your build tool is up to date
pip install build
function install_required_tools () {
echo "build - checking the required tools..."

# Setuptools is a package development process library designed
# for creating and distributing Python packages.
pip install setuptools
# Make sure your build tool is up to date
pip install build

# The Wheel package provides a bdist_wheel command for setuptools.
# It creates .whl file which is directly installable through the pip install command.
pip install wheel
# Setuptools is a package development process library designed
# for creating and distributing Python packages.
pip install setuptools

# This is a smart progress meter used internally by Twine.
pip install tqdm
# The Wheel package provides a bdist_wheel command for setuptools.
# It creates .whl file which is directly installable through the pip install command.
pip install wheel

# The Twine package provides a secure, authenticated,
# and verified connection between your system and PyPi over HTTPS.
pip install twine
# This is a smart progress meter used internally by Twine.
pip install tqdm

echo "build - checking dependencies..."
pip install -r ./requirements.txt
# The Twine package provides a secure, authenticated,
# and verified connection between your system and PyPi over HTTPS.
pip install twine
}

echo "build - compiling package..."
# This will create build, dist and project.egg.info folders
python3 setup.py bdist_wheel

echo "build - uploading dist/* to PyPi..."
twine upload dist/* --verbose
function install_dependencies () {
echo "build - checking dependencies..."
pip install -r ./requirements.txt
}

echo "build - cleaning"
rm -rf ./build/ ./dist/ ./batspp/batspp.egg-info

echo "build - finish!"
# Upload to pypi
#
# $1 -> "test" or "main"
function upload_pypi () {
echo "build - compiling package..."
# This will create build, dist and project.egg.info folders
python3 setup.py bdist_wheel

echo "build - uploading to PyPi..."

# Uploading to Test Pypi
#
# More information here
# https://packaging.python.org/en/latest/guides/using-testpypi/
if [ "$1" == 'main' ]
then
twine upload dist/* --verbose
elif [ "$1" == 'test' ]
then
twine upload --repository testpypi dist/* --verbose
else
echo "no Pypi main|test selected"
fi
}


function clean () {
echo "build - cleaning"
rm -rf ./build/ ./dist/ ./batspp/batspp.egg-info
}


function main () {
if [[ "$1" == "main"|| "$1" == "test" ]]
then
install_required_tools
install_dependencies
upload_pypi "$1"
clean
else
echo 'Upload Batspp dist'
echo ''
echo 'Usage:'
echo "- upload main Pypi: $ $0 main"
echo "- upload test Pypi: $ $0 test"
echo ''
fi
}

main $@

0 comments on commit 9a5dbae

Please sign in to comment.