コード例 #1
0
 def test_norun_resume_nosave(self):
     pypreprocessor.run = False
     pypreprocessor.resume = True
     pypreprocessor.save = False
     pypreprocessor.parse()
     self.assertFalse(os.path.exists(pypreprocessor.output))
     pass
コード例 #2
0
 def test_mode(self):
     pypreprocessor.mode = 'ppcont'
     pypreprocessor.run = True
     pypreprocessor.resume = True
     pypreprocessor.save = False
     pypreprocessor.parse()
     self.assertFalse(os.path.exists(pypreprocessor.output))
     pass
コード例 #3
0
 def test_norun_noresume_save(self):
     pypreprocessor.run = False
     pypreprocessor.resume = False
     pypreprocessor.save = True
     with self.assertRaises(SystemExit) as e:
         pypreprocessor.parse()
     self.assertEqual(e.exception.code, 0)
     self.assertTrue(os.path.exists(pypreprocessor.output))
     pass
コード例 #4
0
 def test_escapeChar(self):
     pypreprocessor.escapeChar = '$'
     pypreprocessor.escape = '#[pypreprocessor]#'
     pypreprocessor.run = True
     pypreprocessor.resume = True
     pypreprocessor.save = False
     pypreprocessor.parse()
     self.assertFalse(os.path.exists(pypreprocessor.output))
     pass
コード例 #5
0
outputFile = 'output_file.py'

#exclude
# run the script in 'debug' mode
if 'debug' in sys.argv:
    pypreprocessor.defines.append('debug')

# run the script in 'production' mode
if 'production' in sys.argv:
    pypreprocessor.defines.append('production')
    pypreprocessor.output = outputFile
    pypreprocessor.removeMeta = True

# run the script in 'postprocessed' mode
if 'postprocessed' in sys.argv:
    pypreprocessor.defines.append('postprocessed')
    pypreprocessor.output = outputFile

pypreprocessor.parse()
#endexclude
#ifdef debug
print('This script is running in \'debug\' mode')
#ifdef production
print('This script is running in \'production\' mode')
print('To see the output open ' + outputFile)
#ifdef postprocessed
print('This script is running in \'postprocessed\' mode')
print('To see the output open ' + outputFile)
#endif
コード例 #6
0
#!/usr/bin/env python
# test.py

import sys
from pypreprocessor import pypreprocessor

pypreprocessor.parse()

print('Testing Python ' + sys.version[:3] + ':')

tests = []

# #define test
#define testdefine
#ifdef testdefine
tests += ['#define: passed']
#else
tests += ['#define: failed']
#endif

#ifdefnot testdefine
tests += ['#definenot: failed']
#else
tests += ['#definenot: passed']
#endif

# #not define test
#ifdef testdefine2
tests += ['#not define: failed']
#else
tests += ['#not define: passed']