Skip to content

Latest commit

 

History

History
102 lines (87 loc) · 4.26 KB

README.md

File metadata and controls

102 lines (87 loc) · 4.26 KB

Python template

  • Click on this link / Use This Template button in the GitHub page above to create a brand new python project with built in build and unit test system enabled.
  • TODO: Edit this file for each project you create.

Building and testing

Prerequisites

  • Verify that Python-3 and pip3 should be installed in your system. terminal>pip3 -V
  • Install pyb: pip3 install pybuilder
  • Verify Pyb installation :pyb --version
# If pyb command is not found, you will have to add pyb to path.
# follow these instructions to add pyb to path.

# for ubuntu/bash:
> echo 'export PATH=$PATH:/<path/to/pyb/bin>' >> ~/.bashrc
# this is usually /home/<home folder>/.local/bin 
> source ~/.bashrc

To build,clean and run tests, use the following command:

Build and test

pyb install_dependencies 
# Pyb should work without pyb install_dependencies, but unfortunately it doesnt.
# See details: here https://github.com/pybuilder/pybuilder/issues/727 
pyb -v
  • That's all you need to build the project.
  • Details about Test failures if any can be found in file target\reports\unittest
  • The binary artifacts will be available in the target folder.

Running Integration Tests

# To skip integration tests during build use the below command
pyb -x run_integration_tests
# To run only integration tests use the below command
pyb run_integration_tests -x run_unit_tests

Clean builds :

  • pyb clean

Reset environment :

  • pyb clean && rm -rf .pybuilder

working with the build system

Running Python Lint Checks

  • This project uses Flake8 as the default linter for coding style enforcement.
  • Refer https://flake8.pycqa.org/en/latest/ for more details.
  • Before raising a pull request contributors are advised to run the below command locally to ensure there are no Flake8 warnings.
 pyb analyze
  • Please ensure build passes on running the above command without any warnings. Examples of Flake 8 warnings shown below:
E501 line too long (125 > 120 characters)
F403 'from local_settings import *' used; unable to detect undefined names
F401 'django.contrib.auth.views as auth_views' imported but unused

IDE/Editor setup

Support is present in source. .idea files are avilable when you clone this repo. Just open the folder in pycharm.

Vim

  • Vim's config file is usually located in ~/.vimrc . Locate the Vim rc file.
  • create/Append the file with this config file.

Project structure

  • Use src/main/python/<module> to add your python module.
  • Write unit tests in src/unittest/ directory mirroring the same module structure in src/main directory.
  • The build artifacts can be found in target directory.

Adding dependencies

 pyb install_dependencies

Writing tests

Follow the above two links on details on how to write tests.

Writing integration tests

Running tests with coverage

Credits