Skip to content

Commit aad1a39

Browse files
committed
Test for distutils module
1 parent 8c5c77d commit aad1a39

File tree

7 files changed

+68
-3
lines changed

7 files changed

+68
-3
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
build/
22
dist/
33
docs/_build
4+
testpkg/build/
5+
testpkg/dist/
6+
testpkg/testpkg/static/css/*.scss.css
47
._.DS_Store
58
.coverage
69
.DS_Store

sasstests.py

+41
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22
from __future__ import with_statement
33

44
import collections
5+
import glob
56
import json
67
import os
78
import os.path
89
import re
910
import shutil
11+
import subprocess
12+
import sys
1013
import tempfile
1114
import unittest
1215
import warnings
@@ -462,6 +465,43 @@ def assert_bytes_equal(self, expected, actual, *args):
462465
*args)
463466

464467

468+
class DistutilsTestCase(unittest.TestCase):
469+
470+
def tearDown(self):
471+
for filename in self.list_built_css():
472+
os.remove(filename)
473+
474+
def css_path(self, *args):
475+
return os.path.join(
476+
os.path.dirname(__file__),
477+
'testpkg', 'testpkg', 'static', 'css',
478+
*args
479+
)
480+
481+
def list_built_css(self):
482+
return glob.glob(self.css_path('*.scss.css'))
483+
484+
def build_sass(self, *args):
485+
testpkg_path = os.path.join(os.path.dirname(__file__), 'testpkg')
486+
return subprocess.call(
487+
[sys.executable, 'setup.py', 'build_sass'] + list(args),
488+
cwd=os.path.abspath(testpkg_path)
489+
)
490+
491+
def test_build_sass(self):
492+
rv = self.build_sass()
493+
self.assertEqual(0, rv)
494+
self.assertEqual(
495+
['a.scss.css'],
496+
list(map(os.path.basename, self.list_built_css()))
497+
)
498+
with open(self.css_path('a.scss.css')) as f:
499+
self.assertEqual(
500+
'p a {\n color: red; }\np b {\n color: blue; }\n',
501+
f.read()
502+
)
503+
504+
465505
class SasscTestCase(unittest.TestCase):
466506

467507
def setUp(self):
@@ -570,6 +610,7 @@ def test_sassc_sourcemap(self):
570610
BuilderTestCase,
571611
ManifestTestCase,
572612
WsgiTestCase,
613+
DistutilsTestCase,
573614
SasscTestCase
574615
]
575616
loader = unittest.defaultTestLoader

sassutils/distutils.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
""":mod:`sassutils.distutils` --- :mod:`setuptools`/:mod:`distutils` integration
2-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1+
""":mod:`sassutils.distutils` --- :mod:`setuptools`/:mod:`distutils` integrat\
2+
ion
3+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\
4+
~~~
35
46
This module provides extensions (and some magical monkey-patches, sorry)
57
of the standard :mod:`distutils` and :mod:`setuptools` (now it's named
@@ -50,7 +52,6 @@
5052
"""
5153
from __future__ import absolute_import
5254

53-
import collections
5455
import distutils.errors
5556
import distutils.log
5657
import distutils.util

testpkg/setup.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from setuptools import setup
2+
3+
4+
setup(
5+
name='testpkg',
6+
packages=['testpkg'],
7+
sass_manifests={
8+
'testpkg': ('static/scss', 'static/css')
9+
},
10+
setup_requires=['libsass']
11+
)

testpkg/testpkg/__init__.py

Whitespace-only changes.

testpkg/testpkg/static/css/README

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
NOTE: Do not delete this file; it's for preserving the directory in Git.

testpkg/testpkg/static/scss/a.scss

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
p {
2+
a {
3+
color: red;
4+
}
5+
b {
6+
color: blue;
7+
}
8+
}

0 commit comments

Comments
 (0)