
import py

def get_version_string():
    fn = py.path.local(__file__).join("..", "..", "..",
                                      "_pytest", "__init__.py")
    for line in fn.readlines():
        if "version" in line:
            return eval(line.split("=")[-1])

def get_minor_version_string():
    return ".".join(get_version_string().split(".")[:2])

if __name__ == "__main__":
    print (get_minor_version_string())


import py

def get_version_string():
    fn = py.path.local(__file__).join("..", "..", "..",
                                      "_pytest", "__init__.py")
    for line in fn.readlines():
        if "version" in line and not line.strip().startswith('#'):
            return eval(line.split("=")[-1])

def get_minor_version_string():
    return ".".join(get_version_string().split(".")[:2])

if __name__ == "__main__":
    print (get_minor_version_string())

Fix getdoctarget to ignore comment lines
Fix getdoctarget to ignore comment lines

  
  import py
  
  def get_version_string():
      fn = py.path.local(__file__).join("..", "..", "..",
                                        "_pytest", "__init__.py")
      for line in fn.readlines():
-         if "version" in line:
+         if "version" in line and not line.strip().startswith('#'):
              return eval(line.split("=")[-1])
  
  def get_minor_version_string():
      return ".".join(get_version_string().split(".")[:2])
  
  if __name__ == "__main__":
      print (get_minor_version_string())
  
Fix getdoctarget to ignore comment lines
## Code Before:

import py

def get_version_string():
    fn = py.path.local(__file__).join("..", "..", "..",
                                      "_pytest", "__init__.py")
    for line in fn.readlines():
        if "version" in line:
            return eval(line.split("=")[-1])

def get_minor_version_string():
    return ".".join(get_version_string().split(".")[:2])

if __name__ == "__main__":
    print (get_minor_version_string())

## Instruction:
Fix getdoctarget to ignore comment lines
## Code After:

import py

def get_version_string():
    fn = py.path.local(__file__).join("..", "..", "..",
                                      "_pytest", "__init__.py")
    for line in fn.readlines():
        if "version" in line and not line.strip().startswith('#'):
            return eval(line.split("=")[-1])

def get_minor_version_string():
    return ".".join(get_version_string().split(".")[:2])

if __name__ == "__main__":
    print (get_minor_version_string())
