|
2 | 2 | from __future__ import with_statement
|
3 | 3 |
|
4 | 4 | import collections
|
| 5 | +import glob |
5 | 6 | import json
|
6 | 7 | import os
|
7 | 8 | import os.path
|
8 | 9 | import re
|
9 | 10 | import shutil
|
| 11 | +import subprocess |
| 12 | +import sys |
10 | 13 | import tempfile
|
11 | 14 | import unittest
|
12 | 15 | import warnings
|
@@ -462,6 +465,43 @@ def assert_bytes_equal(self, expected, actual, *args):
|
462 | 465 | *args)
|
463 | 466 |
|
464 | 467 |
|
| 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 | + |
465 | 505 | class SasscTestCase(unittest.TestCase):
|
466 | 506 |
|
467 | 507 | def setUp(self):
|
@@ -570,6 +610,7 @@ def test_sassc_sourcemap(self):
|
570 | 610 | BuilderTestCase,
|
571 | 611 | ManifestTestCase,
|
572 | 612 | WsgiTestCase,
|
| 613 | + DistutilsTestCase, |
573 | 614 | SasscTestCase
|
574 | 615 | ]
|
575 | 616 | loader = unittest.defaultTestLoader
|
|
0 commit comments