Skip to content

Commit

Permalink
Merge dfeea3f into 6dbf54e
Browse files Browse the repository at this point in the history
  • Loading branch information
weaverba137 committed Jan 29, 2019
2 parents 6dbf54e + dfeea3f commit e9f5109
Show file tree
Hide file tree
Showing 16 changed files with 22 additions and 114 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,3 @@ nosetests.xml

# Mac OSX
.DS_Store

# don't ignore test/bin
!hpsspy/test/bin/*
21 changes: 11 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,18 @@ sudo: false

# The apt packages below are needed for sphinx builds, which can no longer
# be installed with sudo apt-get.
dist: xenial
addons:
apt:
packages:
- graphviz
- texlive-latex-extra
- dvipng
# apt:
# packages:
# - graphviz
# - texlive-latex-extra
# - dvipng
python:
- 2.7
- 3.4
- 3.5
- 3.6
- 3.7-dev
env:
global:
# The following versions are the 'default' for tests, unless
Expand All @@ -47,25 +48,25 @@ matrix:
allow_failures:
- os: osx
- os: linux
python: 3.5
python: 3.6
env: MAIN_CMD='pycodestyle' SETUP_CMD='--count hpsspy'

include:
# Check for sphinx doc build warnings - we do this first because it
# runs for a long time
- os: linux
python: 3.5
python: 3.6
env: SETUP_CMD='build_sphinx --warning-is-error'
# -w is an astropy extension

# Coverage test, pass the results to coveralls.
- os: linux
python: 3.5
python: 3.6
env: MAIN_CMD='coverage' SETUP_CMD='run setup.py test'

# PEP 8 compliance.
- os: linux
python: 3.5
python: 3.6
env: MAIN_CMD='pycodestyle' SETUP_CMD='--count hpsspy'

# before_install:
Expand Down
8 changes: 4 additions & 4 deletions doc/using.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ display all of them. Just the short versions of the commands are
shown here.

-c DIR Cache files (described below) are written to
``$HOME/scratch`` by default. This option
``$HOME/cache`` by default. This option
allows the user to choose any directory.
-D Delete and recreate the disk cache file
(described below).
Expand Down Expand Up @@ -54,7 +54,7 @@ Cache Files
+++++++++++

:command:`missing_from_hpss` uses a few cache files primarily to reduce
memory footprint. These files will be stored in ``$HOME/scratch``
memory footprint. These files will be stored in ``$HOME/cache``
by default. The files are:

Disk Cache
Expand All @@ -68,7 +68,7 @@ HPSS Cache
the command-line. This is simply a list of files found on HPSS.

Missing File Cache
A JSON file of the form ``$HOME/scratch/missing_files_<section>.json``,
A JSON file of the form ``$HOME/cache/missing_files_<section>.json``,
where ``<section>`` is the section (as defined above) specified on the
command-line. It contains a map of HPSS archive files to the files that
belong in that archive. In addition the size of the resulting files
Expand All @@ -83,7 +83,7 @@ Testing and Quality Assurance

To test a configuration file just run :command:`missing_from_hpss` with the
``--test`` option as described above. Aside from creating cache files in
a scratch directory as described above, this mode will not alter any of the
a directory as described above, this mode will not alter any of the
data, neither on disk nor on HPSS.

In addition to validating JSON files and regular expressions, as
Expand Down
3 changes: 0 additions & 3 deletions hpsspy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
Python interface to the HPSS system.
"""
#
from __future__ import (absolute_import, division, print_function,
unicode_literals)


class HpssError(Exception):
Expand Down
5 changes: 0 additions & 5 deletions hpsspy/os/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@
Reproduces some features of the Python built-in :mod:`os`.
"""
#
from __future__ import (absolute_import, division, print_function,
unicode_literals)
#
# from . import path
from ._os import *

import re
Expand Down
4 changes: 0 additions & 4 deletions hpsspy/os/_os.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
Contains the actual functions in :mod:`hpsspy.os`.
"""
#
from __future__ import (absolute_import, division, print_function,
unicode_literals)
#
from .. import HpssOSError
from ..util import HpssFile, hsi

Expand Down
3 changes: 0 additions & 3 deletions hpsspy/os/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
Reproduces some features of the Python built-in :mod:`os.path`.
"""
#
from __future__ import (absolute_import, division, print_function,
unicode_literals)


def isdir(path):
Expand Down
6 changes: 1 addition & 5 deletions hpsspy/scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
Functions for scanning directory trees to find files in need of backup.
"""
#
from __future__ import (absolute_import, division, print_function,
unicode_literals)
#
import csv
import json
import logging
Expand Down Expand Up @@ -561,7 +557,7 @@ def main():
parser = ArgumentParser(prog=os.path.basename(argv[0]), description=desc)
parser.add_argument('-c', '--cache-dir', action='store', dest='cache',
metavar='DIR',
default=os.path.join(os.environ['HOME'], 'scratch'),
default=os.path.join(os.environ['HOME'], 'cache'),
help=('Write cache files to DIR (Default: ' +
'%(default)s).'))
parser.add_argument('-D', '--clobber-disk', action='store_true',
Expand Down
5 changes: 1 addition & 4 deletions hpsspy/test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
Used to initialize the unit test framework via ``python setup.py test``.
"""
from __future__ import (absolute_import, division,
print_function, unicode_literals)
# The line above will help with 2to3 support.
import unittest
from os.path import dirname


def hpsspy_test_suite():
Expand All @@ -18,7 +16,6 @@ def hpsspy_test_suite():
This is factored out separately from runtests() so that it can be used by
``python setup.py test``.
"""
from os.path import dirname
py_dir = dirname(dirname(__file__))
return unittest.defaultTestLoader.discover(py_dir,
top_level_dir=dirname(py_dir))
Expand Down
3 changes: 0 additions & 3 deletions hpsspy/test/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
Check the associated data files.
"""
from __future__ import (absolute_import, division, print_function,
unicode_literals)
#
import unittest
import json
from pkg_resources import resource_exists, resource_stream
Expand Down
33 changes: 2 additions & 31 deletions hpsspy/test/test_os.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@
Test the functions in the os subpackage.
"""
#
from __future__ import (absolute_import, division, print_function,
unicode_literals)
#
import unittest
from unittest.mock import call, patch, MagicMock
# import json
# from pkg_resources import resource_filename
import os
Expand All @@ -19,20 +16,14 @@
from ..os.path import isdir, isfile, islink
from .. import HpssOSError

mock_available = True
try:
from unittest.mock import call, patch, MagicMock
except ImportError:
mock_available = False


class TestOs(unittest.TestCase):
"""Test the functions in the os subpackage.
"""

@classmethod
def setUpClass(cls):
cls.PY3 = sys.version_info[0] > 2
pass

@classmethod
def tearDownClass(cls):
Expand All @@ -44,8 +35,6 @@ def setUp(self):
def tearDown(self):
pass

@unittest.skipUnless(mock_available,
"Skipping test that requires unittest.mock.")
def test_chmod(self):
"""Test the chmod() function.
"""
Expand All @@ -60,8 +49,6 @@ def test_chmod(self):
chmod('/home/b/bweaver/foo.txt', 0o664)
h.assert_called_with('chmod', '436', '/home/b/bweaver/foo.txt')

@unittest.skipUnless(mock_available,
"Skipping test that requires unittest.mock.")
def test_listdir(self):
"""Test the listdir() function.
"""
Expand All @@ -88,8 +75,6 @@ def test_listdir(self):
h.assert_called_with('ls', '-la', '/home/b/bweaver')
self.assertTrue(files[0].ishtar)

@unittest.skipUnless(mock_available,
"Skipping test that requires unittest.mock.")
def test_makedirs(self):
"""Test the makedirs() function.
"""
Expand All @@ -110,8 +95,6 @@ def test_makedirs(self):
makedirs('/home/b/bweaver')
h.assert_called_with('mkdir', '-p', '/home/b/bweaver')

@unittest.skipUnless(mock_available,
"Skipping test that requires unittest.mock.")
def test_mkdir(self):
"""Test the mkdir() function.
"""
Expand All @@ -130,8 +113,6 @@ def test_mkdir(self):
mkdir('/home/b/bweaver')
h.assert_called_with('mkdir', '/home/b/bweaver')

@unittest.skipUnless(mock_available,
"Skipping test that requires unittest.mock.")
def test_stat(self):
"""Test the stat() function.
"""
Expand Down Expand Up @@ -189,8 +170,6 @@ def test_stat(self):
# h.assert_has_calls([call('ls', '-ld', 'cosmo'),
# call('ls', '-ld', 'cosmo.old')])

@unittest.skipUnless(mock_available,
"Skipping test that requires unittest.mock.")
def test_lstat(self):
"""Test the lstat() function.
"""
Expand All @@ -208,8 +187,6 @@ def test_lstat(self):
s = lstat("test")
self.assertFalse(s.islink)

@unittest.skipUnless(mock_available,
"Skipping test that requires unittest.mock.")
def test_isdir(self):
"""Test the isdir() function.
"""
Expand All @@ -219,8 +196,6 @@ def test_isdir(self):
self.assertTrue(isdir('test'))
h.assert_called_with('ls', '-ld', 'test')

@unittest.skipUnless(mock_available,
"Skipping test that requires unittest.mock.")
def test_isfile(self):
"""Test the isfile() function.
"""
Expand All @@ -230,8 +205,6 @@ def test_isfile(self):
self.assertTrue(isfile('desi/cosmos_nvo.tar'))
h.assert_called_with('ls', '-ld', 'desi/cosmos_nvo.tar')

@unittest.skipUnless(mock_available,
"Skipping test that requires unittest.mock.")
def test_islink(self):
"""Test the islink() function.
"""
Expand All @@ -242,8 +215,6 @@ def test_islink(self):
self.assertTrue(islink('cosmo'))
h.assert_called_with('ls', '-ld', 'cosmo')

@unittest.skipUnless(mock_available,
"Skipping test that requires unittest.mock.")
def test_walk(self):
"""Test the walk() function.
"""
Expand Down
5 changes: 0 additions & 5 deletions hpsspy/test/test_scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
Test the functions in the scan subpackage.
"""
#
from __future__ import (absolute_import, division, print_function,
unicode_literals)
#
import unittest
import json
import os
Expand Down Expand Up @@ -44,7 +40,6 @@ class TestScan(unittest.TestCase):

@classmethod
def setUpClass(cls):
cls.PY3 = sys.version_info[0] > 2
logging.getLogger('hpsspy.scan').addHandler(TestHandler())
# cls.logger.setLevel(logging.DEBUG)
# log_format = '%(asctime)s %(name)s %(levelname)s: %(message)s'
Expand Down
9 changes: 1 addition & 8 deletions hpsspy/test/test_top_level.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
Test top-level hpsspy functions.
"""
#
from __future__ import (absolute_import, division,
print_function, unicode_literals)
# The line above will help with 2to3 support.
import unittest
import re
import sys
Expand Down Expand Up @@ -38,10 +34,7 @@ def tearDown(self):
def test_version(self):
"""Ensure the version conforms to PEP386/PEP440.
"""
if sys.version_info.major == 3:
self.assertRegex(theVersion, self.versionre)
else:
self.assertRegexpMatches(theVersion, self.versionre)
self.assertRegex(theVersion, self.versionre)


def test_suite():
Expand Down
Loading

0 comments on commit e9f5109

Please sign in to comment.