Skip to content
This repository has been archived by the owner on Feb 9, 2021. It is now read-only.

Commit

Permalink
Merge d35544b into 97521c5
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-urbanczyk authored Feb 7, 2018
2 parents 97521c5 + d35544b commit c8fe5f8
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 28 deletions.
48 changes: 34 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,50 @@
language: python

matrix:
include:
- python: 2.7
- python: 3.6
env: FREECAD_LIB="$HOME/miniconda/envs/freecad_cq3/lib/"

before_install:
- sudo add-apt-repository -y ppa:freecad-maintainers/freecad-stable
- sudo apt-get update -qq
- if [[ "$TRAVIS_PYTHON_VERSION" == "3.6" ]]; then
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
bash miniconda.sh -b -p $HOME/miniconda;
export PATH="$HOME/miniconda/bin:$PATH";
hash -r;
conda config --set always_yes yes --set changeps1 no;
conda update -q conda;
conda info -a;
conda create -y -q -n freecad_cq3 -c freecad -c conda-forge freecad=0.17 python=3.6 pyparsing conda mock;
source ~/miniconda/bin/activate freecad_cq3;
else
sudo add-apt-repository -y ppa:freecad-maintainers/freecad-stable;
sudo apt-get update -qq;
sudo apt-get install -y freecad freecad-doc;
pip install -r requirements-dev.txt;
pip install travis-sphinx;
pip install sphinx_rtd_theme;
fi

install:
- sudo apt-get install -y freecad freecad-doc
- gcc --version
- g++ --version
- python ./setup.py install
- pip install -r requirements-dev.txt
- pip install travis-sphinx
- pip install sphinx_rtd_theme
- python setup.py install;

script:
- coverage run --source=cadquery ./runtests.py
- travis-sphinx build --nowarn --source=doc
- if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
coverage run --source=cadquery ./runtests.py;
travis-sphinx build --nowarn --source=doc;
fi
- python runtests.py

after_success:
after_script:
- coveralls
- travis-sphinx deploy

branches:
except:
- pythonocc
- 2_0_branch

deploy:
deploy:
provider: pypi
user: dcowden
password:
Expand Down
4 changes: 2 additions & 2 deletions cadquery/freecad_impl/exporters.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def exportShape(shape,exportType,fileLike,tolerance=0.1):
else:
raise ValueError("No idea how i got here")

res = readAndDeleteFile(outFileName)
res = '{}'.format(readAndDeleteFile(outFileName))
fileLike.write(res)

def readAndDeleteFile(fileName):
Expand Down Expand Up @@ -161,7 +161,7 @@ def writeAmf(self,outFile):
v3 = ET.SubElement(triangle,'v3')
v3.text = str(t[2])

ET.ElementTree(amf).write(outFile,encoding="unicode",xml_declaration=True)
ET.ElementTree(amf).write(outFile,xml_declaration=True)

"""
Objects that represent
Expand Down
4 changes: 2 additions & 2 deletions cadquery/freecad_impl/geom.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
You should have received a copy of the GNU Lesser General Public
License along with this library; If not, see <http://www.gnu.org/licenses/>
"""

from __future__ import division
import math
from copy import copy
import cadquery
Expand Down Expand Up @@ -227,7 +227,7 @@ def __sub__(self, v):
def __mul__(self, scalar):
return self.multiply(scalar)

def __div__(self, scalar):
def __truediv__(self, scalar):
if scalar == 0:
raise ZeroDivisionError("%r division by zero" % (type(self)))
return self.multiply(1. / scalar)
Expand Down
5 changes: 4 additions & 1 deletion runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,7 @@
suite.addTests(unittest.TestLoader().loadTestsFromTestCase(TestExporters.TestExporters))
suite.addTests(unittest.TestLoader().loadTestsFromTestCase(TestImporters.TestImporters))
suite.addTests(unittest.TestLoader().loadTestsFromTestCase(TestLogging.TestLogging))
unittest.TextTestRunner().run(suite)

if __name__ == '__main__':
result = unittest.TextTestRunner().run(suite)
sys.exit(not result.wasSuccessful())
4 changes: 2 additions & 2 deletions tests/TestCQGI.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def test_build_with_exception(self):
result = model.build({})
self.assertFalse(result.success)
self.assertIsNotNone(result.exception)
self.assertTrue(result.exception.message == "ERROR")
self.assertTrue(result.exception.args[0] == "ERROR")

def test_that_invalid_syntax_in_script_fails_immediately(self):
badscript = textwrap.dedent(
Expand All @@ -114,7 +114,7 @@ def test_that_invalid_syntax_in_script_fails_immediately(self):
with self.assertRaises(Exception) as context:
model = cqgi.CQModel(badscript)

self.assertTrue('invalid syntax' in context.exception)
self.assertTrue('invalid syntax' in context.exception.args)

def test_that_two_results_are_returned(self):
script = textwrap.dedent(
Expand Down
1 change: 1 addition & 0 deletions tests/TestCadObjects.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#system modules
from __future__ import division
import sys
import unittest
from math import pi, sin, sqrt, radians
Expand Down
23 changes: 16 additions & 7 deletions tests/TestExporters.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""
Tests basic workplane functionality
"""
#from __future__ import unicode_literals

#core modules
import io

Expand All @@ -18,13 +20,20 @@ def _exportBox(self,eType,stringsToFind):
returns the result in case the case wants to do more checks also
"""
p = Workplane("XY").box(1,2,3)
s = io.StringIO()
exporters.exportShape(p,eType,s,0.1)

result = s.getvalue()
#print result
for q in stringsToFind:
self.assertTrue(result.find(q) > -1 )

if eType == exporters.ExportTypes.AMF:
s = io.BytesIO()
exporters.exportShape(p,eType,s,0.1)
result = s.getvalue()
for q in stringsToFind:
self.assertTrue(result.decode().find(q) > -1 )
else:
s = io.StringIO()
exporters.exportShape(p,eType,s,0.1)
result = s.getvalue()
for q in stringsToFind:
self.assertTrue(result.find(q) > -1 )

return result

def testSTL(self):
Expand Down

0 comments on commit c8fe5f8

Please sign in to comment.