# Path: marvin_python_toolbox/management/pkg.py
# def copy(src, dest, ignore=('.git', '.pyc', '__pycache__')):
#     try:
#         shutil.copytree(src, dest, ignore=shutil.ignore_patterns(*ignore))
#     except OSError as e:
#         if e.errno == errno.ENOTDIR:
#             shutil.copy(src, dest)
#         else:
#             print('Directory not copied. Error: %s' % e)


import sys
import os
import os.path
import subprocess
import shutil
import tempfile
import click
from .pkg import copy
@click.option('--cov/--no-cov', default=True)
@click.option('--no-capture', is_flag=True)
@click.option('--pdb', is_flag=True)
@click.argument('args', default='')
@click.pass_context
def test(ctx, cov, no_capture, pdb, args):
    os.environ['TESTING'] = 'true'

    if args:
        args = args.split(' ')
    else:
        args = ['tests']

    if no_capture:
        args += ['--capture=no']

    if pdb:
        args += ['--pdb']

    cov_args = []
    if cov:
        cov_args += ['--cov', os.path.relpath(ctx.obj['package_path'],
                                              start=ctx.obj['base_path']),
                     '--cov-report', 'html',
                     '--cov-report', 'xml',
                     '--cov-report', 'term-missing',
                     ]

    command = ['py.test'] + cov_args + args
    print(' '.join(command))

# Path: marvin_python_toolbox/management/pkg.py
# def copy(src, dest, ignore=('.git', '.pyc', '__pycache__')):
#     try:
#         shutil.copytree(src, dest, ignore=shutil.ignore_patterns(*ignore))
#     except OSError as e:
#         if e.errno == errno.ENOTDIR:
#             shutil.copy(src, dest)
#         else:
#             print('Directory not copied. Error: %s' % e)


# Path: marvin_python_toolbox/management/test.py
import sys
import os
import os.path
import subprocess
import shutil
import tempfile
import click
from .pkg import copy

@click.option('--cov/--no-cov', default=True)
@click.option('--no-capture', is_flag=True)
@click.option('--pdb', is_flag=True)
@click.argument('args', default='')
@click.pass_context
def test(ctx, cov, no_capture, pdb, args):
    os.environ['TESTING'] = 'true'

    if args:
        args = args.split(' ')
    else:
        args = ['tests']

    if no_capture:
        args += ['--capture=no']

    if pdb:
        args += ['--pdb']

    cov_args = []
    if cov:
        cov_args += ['--cov', os.path.relpath(ctx.obj['package_path'],
                                              start=ctx.obj['base_path']),
                     '--cov-report', 'html',
                     '--cov-report', 'xml',
                     '--cov-report', 'term-missing',
                     ]

    command = ['py.test'] + cov_args + args
    print(' '.join(command))

    env = os.environ.copy()