summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorIan Cordasco <graffatcolmingov@gmail.com>2016-01-09 12:55:31 -0600
committerIan Cordasco <graffatcolmingov@gmail.com>2016-01-09 12:55:31 -0600
commit1e9878611a93b3af583e222a15c0b4575fc4f027 (patch)
tree5a4d2e9a3d5f5c5db0e3d7c31c78b1b61e0382fc /tests
parent93369e112f290e233c030ba9d0b36360a65649db (diff)
downloadflake8-1e9878611a93b3af583e222a15c0b4575fc4f027.tar.gz
Move unit tests into tests/unit
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/__init__.py0
-rw-r--r--tests/unit/test_notifier.py (renamed from tests/test_notifier.py)0
-rw-r--r--tests/unit/test_option.py52
-rw-r--r--tests/unit/test_trie.py (renamed from tests/test_trie.py)0
4 files changed, 52 insertions, 0 deletions
diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/unit/__init__.py
diff --git a/tests/test_notifier.py b/tests/unit/test_notifier.py
index b0365f3..b0365f3 100644
--- a/tests/test_notifier.py
+++ b/tests/unit/test_notifier.py
diff --git a/tests/unit/test_option.py b/tests/unit/test_option.py
new file mode 100644
index 0000000..d1491eb
--- /dev/null
+++ b/tests/unit/test_option.py
@@ -0,0 +1,52 @@
+"""Unit tests for flake8.options.manager.Option."""
+import mock
+
+from flake8.options import manager
+
+
+def test_to_optparse():
+ """Test conversion to an optparse.Option class."""
+ opt = manager.Option(
+ short_option_name='-t',
+ long_option_name='--test',
+ action='count',
+ parse_from_config=True,
+ normalize_paths=True,
+ )
+ assert opt.normalize_paths is True
+ assert opt.parse_from_config is True
+
+ optparse_opt = opt.to_optparse()
+ assert not hasattr(optparse_opt, 'parse_from_config')
+ assert not hasattr(optparse_opt, 'normalize_paths')
+ assert optparse_opt.action == 'count'
+
+
+@mock.patch('optparse.Option')
+def test_to_optparse_creates_an_option_as_we_expect(Option):
+ """Show that we pass all keyword args to optparse.Option."""
+ opt = manager.Option('-t', '--test', action='count')
+ opt.to_optparse()
+ option_kwargs = {
+ 'action': 'count',
+ 'default': None,
+ 'type': None,
+ 'dest': None,
+ 'callback': None,
+ 'callback_args': None,
+ 'callback_kwargs': None,
+ 'help': None,
+ 'metavar': None,
+ }
+
+ Option.assert_called_once_with(
+ '-t', '--test', **option_kwargs
+ )
+
+
+def test_config_name_generation():
+ """Show that we generate the config name deterministically."""
+ opt = manager.Option(long_option_name='--some-very-long-option-name',
+ parse_from_config=True)
+
+ assert opt.config_name == 'some_very_long_option_name'
diff --git a/tests/test_trie.py b/tests/unit/test_trie.py
index 0a5a0a9..0a5a0a9 100644
--- a/tests/test_trie.py
+++ b/tests/unit/test_trie.py