Browse files

test and tweaks for PhantomJS 1.3 support

  • Loading branch information...
1 parent 21df979 commit 53f7a1411fd050a10d7de288f6891c6bf4cf5cef @nrabinowitz committed Sep 28, 2011
Showing with 19 additions and 5 deletions.
  1. +3 −4 bin/pjscrape.bat
  2. +5 −0 tests/file_output_config.js
  3. +11 −1 tests/runtests.py
View
7 bin/pjscrape.bat
@@ -1,4 +1,3 @@
-:: Example batch file - place the pjscrape\bin directory in your system PATH.
-:: You might change pyphantomjs to phantomjs if that's what you're using.
-
-pyphantomjs ..\pjscrape\pjscrape.js %1
+:: Example batch file - update the path below, place the batch file in your
+:: system path, and you can run pjscrape as a command
+phantomjs ..\pjscrape\pjscrape.js %*
View
5 tests/file_output_config.js
@@ -0,0 +1,5 @@
+// configuration for file-writing tests
+pjs.config({
+ writer: 'file',
+ outFile: 'C:\\Temp\\pjscrape_out.txt'
+});
View
12 tests/runtests.py
@@ -6,7 +6,8 @@
import os
PORT = 8888
-COMMAND_BASE = ["pyphantomjs", os.path.join('..', 'pjscrape.js'), 'base_config.js']
+COMMAND_BASE = ["phantomjs", os.path.join('..', 'pjscrape.js'), 'base_config.js']
+OUT_FILE = 'C:\Temp\pjscrape_out.txt'
def getPjscrapeOutput(*script_name):
return subprocess.check_output(COMMAND_BASE + list(script_name)).strip()
@@ -137,6 +138,15 @@ def test_404_handling(self):
out = getPjscrapeOutput('test_404_handling.js')
self.assertEqual(out, '["Test Page: Index"]')
+ def test_file_output(self):
+ out = getPjscrapeOutput('file_output_config.js', 'test_basic.js')
+ self.assertEqual(out, '')
+ f = open(OUT_FILE)
+ out = f.read().strip()
+ f.close()
+ self.assertEqual(out, '["Test Page: Index","Page 1","Page 2"]')
+ os.remove(OUT_FILE)
+
if __name__ == '__main__':
# run tests
suite = unittest.TestLoader().loadTestsFromTestCase(TestPjscrape)

0 comments on commit 53f7a14

Please sign in to comment.