Skip to content

Commit

Permalink
Merge pull request #13743 from Avinesh/python-flake8
Browse files Browse the repository at this point in the history
Add regression test for python-flake8 package
  • Loading branch information
dzedro committed Nov 30, 2021
2 parents dbbdf2b + e859085 commit eec9c23
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 0 deletions.
13 changes: 13 additions & 0 deletions data/python/sample.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Sample python file for flake8 test

#An incorrectly formatted comment - pycodestyle E265

# Unused import - pyflakes F401
import os


def sample_print():
print("A sample python program")


sample_print()
1 change: 1 addition & 0 deletions schedule/functional/extra_tests_textmode.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ conditional_schedule:
- console/parsec
- console/systemd_rpm_macros
- console/vsftpd
- console/python_flake8
schedule:
- installation/bootloader_start
- boot/boot_to_desktop
Expand Down
1 change: 1 addition & 0 deletions schedule/functional/extra_tests_textmode_phub.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ schedule:
- boot/boot_to_desktop
- console/add_phub_extension
- console/python_scientific
- console/python_flake8
- '{{wpa_supplicant}}'
- console/vmstat
- console/sssd_389ds_functional
Expand Down
4 changes: 4 additions & 0 deletions schedule/qam/common/mau-extratests-phub.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,16 @@ conditional_schedule:
VERSION:
15-SP3:
- '{{sle15_x86_64}}'
- console/python_flake8
15-SP2:
- '{{sle15_x86_64}}'
- console/python_flake8
15-SP1:
- '{{sle15_x86_64}}'
- console/python_flake8
15:
- '{{sle15_x86_64}}'
- console/python_flake8
sle15_x86_64:
ARCH:
x86_64:
Expand Down
38 changes: 38 additions & 0 deletions tests/console/python_flake8.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# SUSE's openQA tests
#
# Copyright (C) 2021 SUSE LLC
#
# Copying and distribution of this file, with or without modification,
# are permitted in any medium without royalty provided the copyright
# notice and this notice are preserved. This file is offered as-is,
# without any warranty.
# Summary: Regression test for python-flake8
# Maintainer: QE-Core <qe-core@suse.de>


use base "consoletest";
use strict;
use warnings;
use testapi;
use utils 'zypper_call';

sub run {
my $self = shift;
$self->select_serial_terminal;

# Make sure that python-flake8 is installed.
# On SLE, this requires phub extenstion
zypper_call 'in python3-flake8';

# Test case 1: check if flake8 is functional
assert_script_run('mkdir /tmp/empty_dir');
assert_script_run('flake8 /tmp/empty_dir');

# Test case 2: check if flake8 is working as expected
assert_script_run('curl -O ' . data_url("python/sample.py"));
validate_script_output('flake8 --exit-zero sample.py', sub { m/E265 block comment should start with '# '/ && m/F401 'os' imported but unused/ });
script_run('rm sample.py');
script_run('rmdir /tmp/empty_dir');
}

1;

0 comments on commit eec9c23

Please sign in to comment.