Skip to content

Commit

Permalink
Better Django support
Browse files Browse the repository at this point in the history
  • Loading branch information
GaretJax committed Apr 20, 2018
1 parent 42c6d3b commit 455441c
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 12 deletions.
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ env:
- TOXENV=pypy-dj18
- TOXENV=pypy-dj110
- TOXENV=py27-dj111
- TOXENV=py34-dj111
- TOXENV=py35-dj111
- TOXENV=py36-dj111
- TOXENV=pypy-dj111
- TOXENV=py34-dj20
- TOXENV=py35-dj20
- TOXENV=py36-dj20
- TOXENV=pypy-dj20
- TOXENV=flake8

cache:
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2015 Jonathan Stoppani
Copyright (c) 2015-2017 Jonathan Stoppani

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
8 changes: 8 additions & 0 deletions djclick/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ def parse_args(self, args):
class DjangoCommandMixin(object):
use_argparse = False
option_list = []
base_stealth_options = []

@property
def stealth_options(self):
return sum(
([p.name] + [i.lstrip('-') for i in p.opts] for p in self.params),
[],
)

def invoke(self, ctx):
try:
Expand Down
10 changes: 4 additions & 6 deletions djclick/test/test_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ def test_call_cli():

def test_call_command_args():
call_command('testcmd')
with pytest.raises(RuntimeError):
call_command('testcmd', '-r')
with pytest.raises(RuntimeError):
call_command('testcmd', '--raise')

Expand Down Expand Up @@ -219,12 +221,8 @@ def test_django_help(manage):

def test_django_version(manage):
django_version = django.get_version().encode('ascii') + b'\n'
if django.VERSION < (1, 8):
prefix = django_version
else:
prefix = b''
assert manage('testcmd', '--version') == prefix + django_version
assert manage('versioncmd', '--version') == prefix + b'20.0\n'
assert manage('testcmd', '--version') == django_version
assert manage('versioncmd', '--version') == b'20.0\n'


def test_group_command(capsys):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


@click.command()
@click.option('--raise', 'raise_when_called', is_flag=True)
@click.option('-r', '--raise', 'raise_when_called', is_flag=True)
def command(raise_when_called):
if raise_when_called:
raise RuntimeError()
2 changes: 2 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ envlist =
coverage_erase,
py{27,34,35,py}-dj{18,110},
py{27,34,35,36,py}-dj{111},
py{34,35,36,py}-dj{20},
flake8,
coverage_report

Expand All @@ -21,6 +22,7 @@ deps =
dj18: django>=1.8,<1.9
dj110: django>=1.10,<1.11
dj111: django>=1.11,<1.12
dj20: django>=2.0,<2.1
commands = py.test -rxs --cov-report= --cov-append --cov djclick {posargs:djclick}

[testenv:coverage_erase]
Expand Down

0 comments on commit 455441c

Please sign in to comment.