Skip to content

vanilla-project/python-command-line

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vanilla Python Command Line Project

This repository shows a basic setup for a command line application in Python.

Getting Started

Python and Pipenv is expected to be installed on our system.

Installing

After cloning this repository, change into the newly created directory and run

pipenv install --dev

This will install all dependencies needed for the project.

Running the Tests

All tests can be run by executing

pipenv run test

test will invoke pytest which will then find all tests inside the tests directory and run them.

Testing Approach

The test for class Example is only verifying the return value of one method.

Main on the other hand is tested via a test-double that gets injected. This allows us to spy on the output of it. We want to avoid printing anything to the screen while running the tests. Injecting a test double in this instance is a nice way to isolate our application from the command line.

At the bottom of the executable main module sample/main.py we inject sys.stdout, which is Python's variable for its standard output.

Running the Application

To run the application execute the main module sample.main. You should see the text “Python Example” being printed.

$: python -m sample.main
Python Example

Built With

License

This project is licensed under the MIT License - see the license.md file for details.

Releases

No releases published

Packages

No packages published

Languages