Skip to content

Commit

Permalink
Change how cli.py works to make it easier to test (wrap the underlyin…
Browse files Browse the repository at this point in the history
…g internal function)
  • Loading branch information
havocp committed May 17, 2017
1 parent 6aefb9c commit cbecbfe
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
10 changes: 9 additions & 1 deletion anaconda_project/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,12 @@

# the point of this file is to make the internal main() into a public
# entry point.
from anaconda_project.internal.cli.main import main # noqa: F401
import anaconda_project.internal.cli.main as cli_main


def main():
"""anaconda-project command line tool Conda-style entry point.
Conda expects us to take no args and return an exit code.
"""
return cli_main.main()
22 changes: 22 additions & 0 deletions anaconda_project/test/test_cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
# ----------------------------------------------------------------------------
# Copyright © 2016, Continuum Analytics, Inc. All rights reserved.
#
# The full license is in the file LICENSE.txt, distributed with this software.
# ----------------------------------------------------------------------------
from __future__ import absolute_import, print_function

import anaconda_project.cli as cli


def test_main(monkeypatch):
result = {}

def mock_main(*args, **kwargs):
result['args'] = args
result['kwargs'] = kwargs

monkeypatch.setattr('anaconda_project.internal.cli.main.main', mock_main)
cli.main()

assert dict(args=(), kwargs={}) == result

0 comments on commit cbecbfe

Please sign in to comment.