Class: LearnTest::PythonUnittest::PythonChecker

Inherits:
Object
  • Object
show all
Defined in:
lib/learn_test/strategies/python_unittest/requirements_checker.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.checkObject



17
18
19
# File 'lib/learn_test/strategies/python_unittest/requirements_checker.rb', line 17

def self.check
  new.check
end

Instance Method Details

#checkObject



21
22
23
24
25
26
# File 'lib/learn_test/strategies/python_unittest/requirements_checker.rb', line 21

def check
  if !python_installed? || !correct_python_version?
    puts "Please install python 2.7.x or 3.x.x"
    exit
  end
end

#correct_python_version?Boolean

Returns:

  • (Boolean)


32
33
34
35
36
# File 'lib/learn_test/strategies/python_unittest/requirements_checker.rb', line 32

def correct_python_version?
  output = Open3.popen2e('python', '--version')
  version = output[1].read.strip
  !!version.match(/ 2.7.*| 3.*/)
end

#python_installed?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/learn_test/strategies/python_unittest/requirements_checker.rb', line 28

def python_installed?
  !`which python`.empty?
end