Commits

John Chandler committed ebb2163

Added tests and code for includes with single quotes

  • Participants
  • Parent commits fb2f1f6

Comments (0)

Files changed (2)

File qadpid/parser.py

 """
 import re
 
-INCLUDE_RE = re.compile( '(include|require)(?:_once)? "([^"]+)"' )
+INCLUDE_RE = re.compile( '''(include|require)(?:_once)? ["']([^"]+)["']''' )
 
 class PHPFileParser( object ):
     """ PHP File Parser """

File tests/test_parser.py

         """ Test for empty file contents """
         self.assertEquals( self.parser.parse(""), [] )
 
-    def test_parse_one_include( self ):
-        """ Test for presence of one include statement """
+    def test_parse_one_include_double_quotes( self ):
+        """ Test for presence of one include statement - double quotes """
         self.assertEquals( self.parser.parse('include "foo.php"'), [ ("include", "foo.php")] )
 
-    def test_parse_one_require( self ):
-        """ Test for presence of one require statement """
+    def test_parse_one_require_double_quotes( self ):
+        """ Test for presence of one require statement - double quotes """
         self.assertEquals( self.parser.parse('require "foo.php"'), [ ("require", "foo.php")] )
 
+    def test_parse_one_include_single_quotes( self ):
+        """ Test for presence of one include statement - single quotes """
+        self.assertEquals( self.parser.parse("include 'foo.php'"), [ ("include", "foo.php")] )
+
+    def test_parse_one_require_single_quotes( self ):
+        """ Test for presence of one require statement - single quotes """
+        self.assertEquals( self.parser.parse("require 'foo.php'"), [ ("require", "foo.php")] )
+
     def test_parse_one_include_once( self ):
         """ Test for presence of one include_once statement """
         self.assertEquals( self.parser.parse('include_once "foo.php"'), [ ("include", "foo.php")] )