Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unit test for black formatting #261

Merged
merged 4 commits into from
Oct 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
# Prefect Changelog

## 0.4.0 <Badge text="alpha" type="warn">
## Development <Badge text="alpha" type="warn">
### Major Features

- None

### Minor Features

- Add a new method `flow.get_tasks()` for easily filtering flow tasks by attribute [#242](https://github.com/PrefectHQ/prefect/pull/242)
- Add new `JinjaTemplateTask` for easily rendering jinja templates [#200](https://github.com/PrefectHQ/prefect/issues/200)
- Add new `PAUSE` signal for halting task execution [#246](https://github.com/PrefectHQ/prefect/pull/246)
- Add ability to timeout task execution for all executors except `DaskExecutor(processes=True)` [#240](https://github.com/PrefectHQ/prefect/issues/240)
- Add a new method `flow.get_tasks()` for easily filtering flow tasks by attribute - [#242](https://github.com/PrefectHQ/prefect/pull/242)
- Add new `JinjaTemplateTask` for easily rendering jinja templates - [#200](https://github.com/PrefectHQ/prefect/issues/200)
- Add new `PAUSE` signal for halting task execution - [#246](https://github.com/PrefectHQ/prefect/pull/246)
- Add ability to timeout task execution for all executors except `DaskExecutor(processes=True)` - [#240](https://github.com/PrefectHQ/prefect/issues/240)
- Add explicit unit test to check Black formatting (Python 3.6+) - [#261](https://github.com/PrefectHQ/prefect/pull/261)

### Fixes

- Flow consistently raises if passed a parameter that doesn't exist [#149](https://github.com/PrefectHQ/prefect/issues/149)
- Flow consistently raises if passed a parameter that doesn't exist - [#149](https://github.com/PrefectHQ/prefect/issues/149)

### Breaking Changes

Expand All @@ -24,10 +25,10 @@

### Major Features

- Local parallelism with `DaskExecutor` [#151](https://github.com/PrefectHQ/prefect/issues/151), [#186](https://github.com/PrefectHQ/prefect/issues/186)
- Resource throttling based on `tags` [#158](https://github.com/PrefectHQ/prefect/issues/158), [#186](https://github.com/PrefectHQ/prefect/issues/186)
- `Task.map` for mapping tasks [#186](https://github.com/PrefectHQ/prefect/issues/186)
- Added `AirFlow` utility for importing Airflow DAGs as Prefect Flows [#232](https://github.com/PrefectHQ/prefect/pull/232)
- Local parallelism with `DaskExecutor` - [#151](https://github.com/PrefectHQ/prefect/issues/151), [#186](https://github.com/PrefectHQ/prefect/issues/186)
- Resource throttling based on `tags` - [#158](https://github.com/PrefectHQ/prefect/issues/158), [#186](https://github.com/PrefectHQ/prefect/issues/186)
- `Task.map` for mapping tasks - [#186](https://github.com/PrefectHQ/prefect/issues/186)
- Added `AirFlow` utility for importing Airflow DAGs as Prefect Flows - [#232](https://github.com/PrefectHQ/prefect/pull/232)

### Minor Features

Expand Down
14 changes: 14 additions & 0 deletions tests/test_formatting.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import os
import pytest
import shlex
import subprocess
import sys


@pytest.mark.skipif(sys.version_info < (3, 6), reason="Black requires Python 3.6+")
def test_black_formatting():
# make sure we're in the right place
assert __file__.endswith("/tests/test_formatting.py")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain why this assert is necessary?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was worried that this file might get moved inadvertently, without someone necessarily looking at it (for example if the tests directory were restructured), and causing the following line (that runs black against the root) to fail. If there's a way to always get the repo root, I'd use that instead, but I'm not sure how.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok that makes sense, otherwise you might accidentally black check a larger directory or something 👍

prefect_dir = os.path.dirname(os.path.dirname(__file__))
result = subprocess.call(shlex.split("black --check {}".format(prefect_dir)))
assert result == 0, "Prefect repo did not pass Black formatting!"