Skip to content

Commit 94506d4

Browse files
authored
Merge pull request #212 from CLARIAH/dev
Dev changes -- CI testing under windows
2 parents 0b516b0 + e94e895 commit 94506d4

File tree

7 files changed

+18
-10
lines changed

7 files changed

+18
-10
lines changed

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ jobs:
2121
language: objective-c
2222
env: PYENV_VERSION=3.5.2
2323
# command to install dependencies
24+
- stage: Tests
25+
os: windows
26+
language: shell
27+
env: PATH=/c/Python37:/c/Python37/Scripts:$PATH
2428
- stage: deploy
2529
# deploy automatically to pypi
2630
before_deploy:

.travis/before_install.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@ fi
1010
if [[ $TRAVIS_OS_NAME == 'osx' ]]; then
1111
brew install pyenv
1212
pyenv install -s $PYENV_VERSION
13+
elif [[ $TRAVIS_OS_NAME == 'windows' ]]; then
14+
choco install python
1315
fi

.travis/install.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ if [[ $TRAVIS_OS_NAME == 'osx' ]]; then
99
alias pip=pip3
1010
fi
1111
export PATH="/Users/travis/.pyenv/shims:${PATH}"
12+
elif [[ $TRAVIS_OS_NAME == 'windows' ]]; then
13+
alias pip="pip --user"
1214
fi
1315

1416
if [[ $TRAVIS_BUILD_STAGE_NAME == 'Deploy' ]]; then

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
with codecs.open('requirements-test.txt', mode='r') as f:
2222
tests_require = f.read().splitlines()
2323

24-
with codecs.open('README.md', mode='r') as f:
24+
with codecs.open('README.md', mode='r', encoding='utf-8') as f:
2525
long_description = f.read()
2626

2727
setup(

src/fileLoaders.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def __init__(self, user, repo, sha, prov):
5858
self.gh_repo = gh.get_repo(user + '/' + repo, lazy=False)
5959
except BadCredentialsException:
6060
raise Exception('BadCredentials: have you set up github_access_token on config.ini ?')
61-
except Exception as e:
61+
except Exception:
6262
raise Exception('Repo not found: ' + user + '/' + repo)
6363

6464
def fetchFiles(self):
@@ -124,12 +124,11 @@ def __init__(self, baseDir=static.LOCAL_SPARQL_DIR):
124124

125125
def fetchFiles(self):
126126
"""Returns a list of file items contained on the local repo."""
127-
print("Fetching files from {}".format(self.baseDir))
128127
files = glob(path.join(self.baseDir, '*'))
129128
filesDef = []
129+
baseDirSlash = path.join(self.baseDir, '')
130130
for f in files:
131-
print("Found SPARQL file {}".format(f))
132-
relative = f.replace(self.baseDir, '')
131+
relative = f.replace(baseDirSlash, '')
133132
filesDef.append({
134133
'download_url': relative,
135134
'name': relative
@@ -145,7 +144,7 @@ def getTextFor(self, fileItem):
145144
return self._getText(fileItem['download_url'])
146145

147146
def _getText(self, filename):
148-
targetFile = self.baseDir + filename
147+
targetFile = path.join(self.baseDir, filename)
149148
if path.exists(targetFile):
150149
with open(targetFile, 'r') as f:
151150
lines = f.readlines()

tests/mock_data.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from os import path
33
from glob import glob
44

5-
base_url = 'tests/repo/'
5+
base_url = path.join('tests', 'repo')
66
def buildEntry(entryName):
77
entryName = entryName.replace(base_url, '')
88
return {
@@ -11,15 +11,15 @@ def buildEntry(entryName):
1111
u'path': entryName,
1212
u'type': u'file'
1313
}
14-
mock_files = [ buildEntry(f) for f in glob(base_url + '*') ]
14+
mock_files = [ buildEntry(f) for f in glob(path.join(base_url, '*')) ]
1515

1616
def mock_requestsGithub(uri, headers={}, params={}):
1717
if uri.endswith('contents'):
1818
return_value = Mock(ok=True)
1919
return_value.json.return_value = mock_files
2020
return return_value
2121
else:
22-
targetFile = uri.replace('https://raw.githubusercontent.com/fakeuser/fakerepo/master/', base_url)
22+
targetFile = uri.replace('https://raw.githubusercontent.com/fakeuser/fakerepo/master/', path.join(base_url, ''))
2323
if path.exists(targetFile):
2424
f = open(targetFile, 'r')
2525
lines = f.readlines()

tests/test_loaders.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import unittest
22
import six
33
from mock import patch
4+
from os import path
45

56
from grlc.fileLoaders import LocalLoader, GithubLoader
67
from grlc.queryTypes import qType
@@ -77,7 +78,7 @@ def test_getTextForName(self):
7778
class TestLocalLoader(unittest.TestCase):
7879
@classmethod
7980
def setUpClass(self):
80-
self.loader = LocalLoader('./tests/repo/')
81+
self.loader = LocalLoader(path.join('tests', 'repo'))
8182

8283
def test_fetchFiles(self):
8384
files = self.loader.fetchFiles()

0 commit comments

Comments
 (0)