Skip to content

ResearchCodingClub/python-testing-for-research

 
 

Repository files navigation

Python testing for research

A short course on the basics of software testing in Python using the pytest library.

This lesson uses The Carpentries Workbench template.

It is derived from the FAIR2 for Research Software training course python-testing-for-research by the University of Sheffield.

Course Description

Whether you are a seasoned developer or just write the occasional script, it's important to know that your code does what you intend, and will continue to do so as you make changes.

Software testing is a methodology of automatically ensuring that your code works correctly, without having to go back and manually verify after each change.

This course seeks to provide you with conceptual understanding and the tools you need to start ensuring the robustness of your code.

Contents

  • Basic tests
  • Running a test suite & understanding outputs
  • Best practices
  • Testing for errors
  • Testing floating point data
  • Fixtures
  • Parametrisation
  • Testing file outputs
  • Continuous integration & automatic test-running with GitHub

Contributions

Contributions are welcome, please refer to the contribution guidelines of how to do so and ensure that you adhere to the Code of Conduct.

Build the lesson locally

To render the lesson locally, you will need to have R installed. Instructions for using R with the Carpentries template is available on the Carpentries website. We recommend using the {renv} package.

After cloning the repository, you can set up renv and install all packages with:

renv::init()
# Optionally update packages
renv::update()

Once you have installed the dependencies, you can render the pages locally by starting R in the project root and running:

sandpaper::serve()

When building the site subsequently, you may need to run renv::activate() first.

This will build the pages and start a local web-server in R and open it in your browser. These pages are "live" and will respond to local file changes if you save them.

About

A training course on the practical use of tests in research software.

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%