# pytest-aoc
Project description
This pytest plugin downloads puzzle inputs for [Advent of Code][1] and synthesizes fixtures that you can use in your tests.
## Installing and configuring
Installing is easy: pip install pytest-aoc. Next you will need to configure _two_ things: for which event (year) the plugin should download inputs, and a valid session cookie. These are normally valid for about a month or so.
To set the year, put it in setup.cfg:
[tool:pytest] aoc_year = 2018
Then, put a valid session ID in a file named .cookie and also name this file in your .gitignore.
With these two things in place, when running pytest, this plugin will download any missing inputs, and generate pytest fixtures that you can use in your test functions, see ‘Using’ and ‘Fixtures’, below.
## Using
With this plugin properly configured, you can write tests like this:
- def test_01a(day01_numbers):
assert sum(day01_numbers) == 123
Here, the parameter day01_numbers is a fixture that contains the numbers on each line in the file input/day01.txt.
## Fixtures
### dayNN_text
The text in the input file, but stripped of any leading and trailing whitespace.
### dayNN_raw
The raw text in the input file.
### dayNN_lines
A list of lines.
### dayNN_numbers
A list of numbers.
### dayNN_number
A single number.
### dayNN_grid
A list of lists, representing a grid of textual values.
### dayNN_number_grid
A list of lists, representing a grid of numbers.
## Command-line and configuration options
You can pass the options from the command line or set them in setup.cfg. The command line takes precedence.
### –aoc-year / aoc_year
(Mandatory) The year for which to download puzzle inputs.
### –aoc-session-id / aoc_session_id
(Optional) The session ID to use for requesting puzzle inputs.
### –aoc-session-file / aoc_session_file
(Optional; default .cookie) The file from which to read the session ID.
### –aoc-input-dir / aoc_input_dir
(Optional; default input) The directory in which inputs are stored. Will be created if it doesn’t exist.
Home-page: UNKNOWN Author: Joost Molenaar Author-email: j.j.molenaar@gmail.com License: UNKNOWN Description: UNKNOWN Platform: UNKNOWN Classifier: Framework :: Pytest Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3 :: Only Classifier: Programming Language :: Python :: 3.7
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for pytest_aoc-0.1.dev9-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c3092ee55c16bb58fa9c66a43cca1ce011c92fcb7d773549b04b989fcc5afdc9 |
|
MD5 | e45c662a58daa5b62cf65fa2d06bbc53 |
|
BLAKE2b-256 | 7672b42d3031f58f24f86da64f3054f6351c6690b82faf6a5d01b080ae73e354 |