Skip to content

Commit

Permalink
Add alternate requirements option
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeljoseph committed Nov 15, 2013
1 parent 73323c2 commit 8b0e4a9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
2 changes: 1 addition & 1 deletion changes/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
increment options above, this option stops
`changes` from confirming the new version number.
--module-name=<module> If your module and package aren't the same
--requirements=<req> Requirements file name (default: requirements.txt)
--debug Debug output.
The commands do the following:
Expand All @@ -51,7 +52,6 @@
import changes
from changes import config, probe, util, version
from changes.changelog import changelog
from changes.config import arguments
from changes.packaging import install, upload, pypi
from changes.vcs import tag, commit_version_change
from changes.verification import run_tests
Expand Down
26 changes: 15 additions & 11 deletions changes/probe.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@

import sh

from changes import attributes
from changes import attributes, config

log = logging.getLogger(__name__)

REQUIREMENTS = 'requirements.txt'


def has_requirement(dependency, requirements_contents):
return any(
Expand All @@ -29,9 +31,18 @@ def probe_project(module_name):
log.info('setup.py? %s', setup)

# `requirements.txt`
has_requirements = exists('requirements.txt')
log.info('requirements.txt? %s', setup)
requirements_contents = open('requirements.txt').readlines()
requirements = config.arguments.get('--requirements') or REQUIREMENTS
has_requirements = exists(requirements)
log.info('%s? %s', requirements, has_requirements)
if has_requirements:
requirements_contents = open(requirements).readlines()

# supports executing tests with `nosetests` or `tox`
runs_tests = (
has_requirement('nose', requirements_contents) or
has_requirement('tox', requirements_contents)
)
log.info('Runs tests? %s' % runs_tests)

# `CHANGELOG.md`
has_changelog = exists('CHANGELOG.md')
Expand All @@ -46,12 +57,5 @@ def probe_project(module_name):
)
log.info('Has module metadata? %s', has_metadata)

# supports executing tests with `nosetests` or `tox`
runs_tests = (
has_requirement('nose', requirements_contents) or
has_requirement('tox', requirements_contents)
)
log.info('Runs tests? %s' % runs_tests)

return (on_github and setup and has_changelog and has_metadata and
has_requirements and runs_tests)
6 changes: 5 additions & 1 deletion tests/test_probe.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
from changes import probe
from changes import config, probe
from . import BaseTestCase


class ProbeTestCase(BaseTestCase):

def test_probe_project(self):
self.assertTrue(probe.probe_project(self.module_name))

def test_probe_with_alt_requirements(self):
config.arguments['--requirements'] = 'test-requirements.txt'
self.assertFalse(probe.probe_project(self.module_name))

0 comments on commit 8b0e4a9

Please sign in to comment.