import os
import StyleSheet
import pdb
def whiteStrip(txt):
text = txt
text = " ".join(text.split())
return text
def main():
failed = {}
files = os.listdir('_test')
for i in xrange(len(files)):
path = os.path.join('_test', files[i])
if os.path.isfile(path) and os.path.splitext(path)[1] == '.sss':
#pdb.set_trace()
css = os.path.join(os.path.splitext(path)[0] + '.css')
if os.path.isfile(css):
styles = StyleSheet.SSSStyleSheet(path)
result = styles.cssText
result = whiteStrip(result)
# open the CSS file
compare_to = open(css, 'r')
base = compare_to.read()
base = whiteStrip(base)
if result == base:
print '.',
else:
print 'F',
failed[path] = result, base
else:
print "\nCannot find the file: " + css
break
if failed:
for path, output in failed.items():
print "\n\n============================================"
print "The following file FAILED:"
print path
print "--------------------------------------------"
print "The output was:"
print output[0]
print "--------------------------------------------"
print "The expected output was:"
print output[1]
print "============================================"
if __name__ == '__main__':
main()