-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add --version option to show deadcode version
- Loading branch information
Showing
5 changed files
with
56 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
try: | ||
import importlib.metadata | ||
|
||
__version__ = importlib.metadata.version(__package__ or __name__) | ||
except ImportError: | ||
import importlib_metadata | ||
|
||
__version__ = importlib_metadata.version(__package__ or __name__) |
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,41 @@ | ||
from deadcode import __version__ | ||
from deadcode.cli import main | ||
from deadcode.utils.base_test_case import BaseTestCase | ||
|
||
|
||
class TestVersionCliOption(BaseTestCase): | ||
def test_show_version(self): | ||
self.files = { | ||
'foo.py': b""" | ||
class UnusedClass: | ||
pass | ||
print("Dont change this file")""", | ||
'bar.py': b""" | ||
def unused_function(): | ||
pass | ||
print("Dont change this file")""", | ||
} | ||
|
||
result = main('--version'.split()) | ||
|
||
self.assertEqual(result, __version__) | ||
|
||
def test_show_version_when_path_provided(self): | ||
self.files = { | ||
'foo.py': b""" | ||
class UnusedClass: | ||
pass | ||
print("Dont change this file")""", | ||
'bar.py': b""" | ||
def unused_function(): | ||
pass | ||
print("Dont change this file")""", | ||
} | ||
|
||
result = main('. --version'.split()) | ||
|
||
self.assertEqual(result, __version__) |