forked from arkq/flake8-requirements
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for poetry dependency manager
Closed arkq#8
- Loading branch information
Showing
6 changed files
with
134 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import unittest | ||
|
||
from flake8_requirements.checker import Flake8Checker | ||
from flake8_requirements.checker import memoize | ||
|
||
try: | ||
from unittest import mock | ||
builtins_open = 'builtins.open' | ||
except ImportError: | ||
import mock | ||
builtins_open = '__builtin__.open' | ||
|
||
|
||
class PoetryTestCase(unittest.TestCase): | ||
|
||
def setUp(self): | ||
memoize.mem = {} | ||
|
||
def test_get_pyproject_toml_poetry(self): | ||
content = "[tool.poetry]\nname='x'\n[tool.poetry.tag]\nx=0\n" | ||
with mock.patch(builtins_open, mock.mock_open(read_data=content)): | ||
poetry = Flake8Checker.get_pyproject_toml_poetry() | ||
self.assertDictEqual(poetry, {'name': "x", 'tag': {'x': 0}}) | ||
|
||
def test_1st_party(self): | ||
content = "[tool.poetry]\nname='book'\n" | ||
|
||
with mock.patch(builtins_open, mock.mock_open()) as m: | ||
m.side_effect = ( | ||
IOError("No such file or directory: 'setup.py'"), | ||
mock.mock_open(read_data=content).return_value, | ||
) | ||
|
||
checker = Flake8Checker(None, None) | ||
mods = checker.get_mods_1st_party() | ||
self.assertEqual(mods, set([("book",)])) | ||
|
||
def test_3rd_party(self): | ||
content = "[tool.poetry.dependencies]\ntools='1.0'\n" | ||
content += "[tool.poetry.dev-dependencies]\ndev-tools='1.0'\n" | ||
|
||
with mock.patch(builtins_open, mock.mock_open()) as m: | ||
m.side_effect = ( | ||
IOError("No such file or directory: 'setup.py'"), | ||
mock.mock_open(read_data=content).return_value, | ||
) | ||
|
||
checker = Flake8Checker(None, None) | ||
mods = checker.get_mods_3rd_party() | ||
self.assertEqual(mods, set([("tools",), ("dev_tools",)])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters