forked from os-autoinst/os-autoinst-distri-opensuse
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce a new test for Python-BeautifulSoup4
- Loading branch information
Showing
5 changed files
with
450 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import bs4 as bs | ||
with open ("testpage.html") as file: | ||
source = file.read() | ||
|
||
soup=bs.BeautifulSoup(source,'lxml') | ||
assert soup.title.string=='Python Programming Tutorials' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,301 @@ | ||
<html> | ||
|
||
<head> | ||
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Python Programming Tutorials</title> | ||
|
||
<meta name="description" | ||
content="Python Programming tutorials from beginner to advanced on a massive variety of topics. All video and text tutorials are free."> | ||
|
||
<link rel="shortcut icon" href="/static/favicon.ico"> | ||
<link rel="stylesheet" href="/static/css/materialize.min.css"> | ||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> | ||
<meta name="google-site-verification" content="3fLok05gk5gGtWd_VSXbSSSH27F2kr1QqcxYz9vYq2k" /> | ||
<link rel="stylesheet" type="text/css" href="/static/css/bootstrap.css"> | ||
|
||
<style> | ||
@media (min-width:992px) { | ||
#aside { | ||
width: 250px; | ||
} | ||
|
||
pre { | ||
tab-size: 4; | ||
} | ||
|
||
.btn { | ||
background-color: #FFD166; | ||
color: #000; | ||
height: auto; | ||
font-color: #000; | ||
} | ||
|
||
.btn:hover { | ||
background-color: #FFD166; | ||
} | ||
</style> | ||
|
||
|
||
</head> | ||
|
||
<body> | ||
|
||
<div class="navbar-fixed"> | ||
<nav style="background-color:#003F72"> | ||
<div class="nav-wrapper container"> | ||
<a href="/" class="brand-logo"><img class="img-responsive" | ||
style="width:50px; height;50px; margin-top:5px" src="/static/images/mainlogowhitethick.jpg"></a> | ||
<a href="#" data-activates="navsidebar" class="button-collapse"><i class="mdi-navigation-menu"></i></a> | ||
<ul class="right hide-on-med-and-down"> | ||
<li><i class="material-icons">search</i></li> | ||
<li> | ||
<form method='get' id='searchform' style='height:50px; padding-top:10px' action='/search/?l=hi'> | ||
<input name='q' id="search" type="search" placeholder="search" style='font-size:16px'> | ||
</form> | ||
</li> | ||
|
||
<li><a href="/">Home</a></li> | ||
<li><a class="tooltipped" data-position="bottom" data-delay="50" data-tooltip="sudo apt-get upgrade" | ||
href="/+=1/">+=1</a></li> | ||
<!--<li><a href="/store/python-hoodie/">Store</a></li>--> | ||
<li><a href="/support/">Support the Content</a></li> | ||
|
||
<li><a href="https://goo.gl/7zgAVQ" | ||
target='blank'><!--<i class="material-icons">question_answer</i>-->Community</a></li> | ||
<li><a href="/login/">Log in</a></li> | ||
<li><a href="/register/">Sign up</a></li> | ||
|
||
|
||
</ul> | ||
<ul class="side-nav" id="navsidebar"> | ||
<li> | ||
<form method='get' id='searchform' style='height:50px; padding-top:10px' action='/search/?l=hi'> | ||
<input name='q' id="search" type="search" placeholder="search" style='font-size:16px'> | ||
</form> | ||
</li> | ||
|
||
<li><a href="/">Home</a></li> | ||
<li><a class="tooltipped" data-position="bottom" data-delay="50" data-tooltip="sudo apt-get upgrade" | ||
href="/+=1/">+=1</a></li> | ||
<!--<li><a href="/store/python-hoodie/">Store</a></li>--> | ||
<li><a href="/support/">Support the Content</a></li> | ||
|
||
<li><a href="https://goo.gl/7zgAVQ" | ||
target='blank'><!--<i class="material-icons">question_answer</i>-->Community</a></li> | ||
<li><a href="/login/">Log in</a></li> | ||
<li><a href="/register/">Sign up</a></li> | ||
|
||
|
||
</ul> | ||
</div> | ||
</nav> | ||
</div> | ||
|
||
|
||
|
||
<!-- main content --> | ||
<div class="container" style="max-width:1500px; min-height:100%"> | ||
<!--Notification:--> | ||
<!--<p style="font-size:80%">TensorFlow.js Livestream: <a href="https://www.youtube.com/watch?v=NjSlj95lliM" target="blank"><strong>Deep Learning in the browser</strong></a></p>--> | ||
<!--End Notification:--> | ||
|
||
|
||
<div class="body"> | ||
|
||
<p class='introduction'>Oh, hello! This is a <span style='font-size:115%'>wonderful</span> page meant to let | ||
you practice web scraping. This page was originally created to help people work with the <a | ||
href="https://www.crummy.com/software/BeautifulSoup/bs4/doc/" target="blank"><strong>Beautiful Soup | ||
4</strong></a> library.</p> | ||
|
||
<p>The following table gives some general information for the following <code>programming languages</code>: | ||
</p> | ||
|
||
<ul> | ||
<li>Python</li> | ||
<li>Pascal</li> | ||
<li>Lisp</li> | ||
<li>D#</li> | ||
<li>Cobol</li> | ||
<li>Fortran</li> | ||
<li>Haskell</li> | ||
</ul> | ||
|
||
|
||
<table style="width:100%"> | ||
|
||
<tr> | ||
<th>Program Name</th> | ||
<th>Internet Points</th> | ||
<th>Kittens?</th> | ||
</tr> | ||
|
||
<tr> | ||
<td>Python</td> | ||
<td>932914021</td> | ||
<td>Definitely</td> | ||
</tr> | ||
|
||
<tr> | ||
<td>Pascal</td> | ||
<td>532</td> | ||
<td>Unlikely</td> | ||
</tr> | ||
|
||
|
||
<tr> | ||
<td>Lisp</td> | ||
<td>1522</td> | ||
<td>Uncertain</td> | ||
</tr> | ||
|
||
|
||
<tr> | ||
<td>D#</td> | ||
<td>12</td> | ||
<td>Possibly</td> | ||
</tr> | ||
|
||
|
||
<tr> | ||
<td>Cobol</td> | ||
<td>3</td> | ||
<td>No.</td> | ||
</tr> | ||
|
||
<tr> | ||
<td>Fortran</td> | ||
<td>52124</td> | ||
<td>Yes.</td> | ||
</tr> | ||
|
||
<tr> | ||
<td>Haskell</td> | ||
<td>24</td> | ||
<td>lol.</td> | ||
</tr> | ||
|
||
</table> | ||
|
||
<p>I think it's clear that, on a scale of 1-10, python is:</p> | ||
|
||
<div class='card hoverable'> | ||
<div class='card-content'> | ||
<div class='card-title'></div> | ||
<img class="responsive-img" | ||
src="https://s-media-cache-ak0.pinimg.com/originals/e8/2a/ff/e82aff2876b080675449d0cef7685321.jpg" | ||
alt="omg batman" /> | ||
</div> | ||
</div> | ||
|
||
<p>Javascript (dynamic data) test:</p> | ||
<p class='jstest' id='yesnojs'>y u bad tho?</p> | ||
<script> | ||
document.getElementById('yesnojs').innerHTML = 'Look at you shinin!'; | ||
</script> | ||
|
||
<br><br> | ||
|
||
<pre>Beautiful is better than ugly. | ||
Explicit is better than implicit. | ||
Simple is better than complex. | ||
Complex is better than complicated. | ||
Flat is better than nested. | ||
Sparse is better than dense. | ||
Readability counts. | ||
Special cases aren't special enough to break the rules. | ||
Although practicality beats purity. | ||
Errors should never pass silently. | ||
Unless explicitly silenced. | ||
In the face of ambiguity, refuse the temptation to guess. | ||
There should be one-- and preferably only one --obvious way to do it. | ||
Although that way may not be obvious at first unless you're Dutch. | ||
Now is better than never. | ||
Although never is often better than *right* now. | ||
If the implementation is hard to explain, it's a bad idea. | ||
If the implementation is easy to explain, it may be a good idea. | ||
Namespaces are one honking great idea -- let's do more of those!</pre> | ||
|
||
<p>Whᶐt hαppéns now¿</p> | ||
|
||
<p><a href="/sitemap.xml" target="blank"><strong>sitemap</strong></a></p> | ||
|
||
</body> | ||
|
||
|
||
</div> | ||
</div> | ||
|
||
<!--login modal--> | ||
|
||
|
||
<!--Register modal--> | ||
|
||
|
||
|
||
<script> | ||
$(document).ready(function () { | ||
$(".button-collapse").sideNav(); | ||
$('.modal-trigger').leanModal(); | ||
$('.collapsible').collapsible({ | ||
accordion: false // A setting that changes the collapsible behavior to expandable instead of the default accordion style | ||
}); | ||
$('#aside').pushpin({ top: 110, bottom: 500 }); | ||
}); | ||
</script> | ||
<script> | ||
$(document).ready(function () { | ||
$('.collapsible').collapsible({ | ||
accordion: false // A setting that changes the collapsible behavior to expandable instead of the default accordion style | ||
}); | ||
$('select').material_select(); | ||
}); | ||
</script> | ||
<script> | ||
function goBack() { | ||
window.history.back() | ||
} | ||
</script> | ||
<script type="text/javascript" src="/static/js/run_prettify.js"></script> | ||
|
||
</body> | ||
|
||
<footer class="page-footer"> | ||
<div class="container"> | ||
<div class="row"> | ||
<div class="col l6 s12"> | ||
<h5 class="white-text">You've reached the end!</h5> | ||
|
||
<p class="grey-text text-lighten-4">Contact: [email protected].</p> | ||
<ul> | ||
<li><a class="grey-text text-lighten-3" href="/support-donate/">Support this Website!</a></li> | ||
<li><a class="grey-text text-lighten-3" href="/consulting/">Consulting and Contracting</a></li> | ||
<li><a class="grey-text text-lighten-3" | ||
href="https://www.facebook.com/pythonprogramming.net/">Facebook</a></li> | ||
<li><a class="grey-text text-lighten-3" href="https://twitter.com/sentdex">Twitter</a></li> | ||
<li><a class="grey-text text-lighten-3" href="https://instagram.com/sentdex">Instagram</a></li> | ||
</ul> | ||
</div> | ||
<div class="col l4 offset-l2 s12"> | ||
<h6 class="white-text">Legal stuff:</h6> | ||
<ul> | ||
<li><a class="grey-text text-lighten-3" href="/about/tos/">Terms and Conditions</a></li> | ||
<li><a class="grey-text text-lighten-3" href="/about/privacy-policy/">Privacy Policy</a></li> | ||
|
||
</ul> | ||
</div> | ||
</div> | ||
</div> | ||
<a href="https://xkcd.com/353/" target='blank'> | ||
<p class="grey-text right" style='padding-right:10px'>Programming is a superpower.</p> | ||
</a> | ||
<div class="footer-copyright"> | ||
<div class="container"> | ||
© OVER 9000! PythonProgramming.net | ||
|
||
</div> | ||
|
||
</div> | ||
</footer> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# Copyright 2015-2022 SUSE LLC | ||
# SPDX-License-Identifier: GPL-2.0-or-later | ||
|
||
package python_version_utils; | ||
|
||
use base Exporter; | ||
use Exporter; | ||
use testapi; | ||
use utils 'zypper_call'; | ||
use strict; | ||
use warnings; | ||
use feature qw(signatures); | ||
|
||
|
||
our @EXPORT = qw( | ||
get_system_python_version | ||
get_available_python_versions | ||
get_python3_specific_release | ||
remove_installed_pythons | ||
); | ||
|
||
=head2 get_system_python_version | ||
returns a string with the system's current default python version, for example 'python311' | ||
=cut | ||
sub get_system_python_version() { | ||
my @system_python_version = script_output(qq[zypper se --installed-only --provides '/usr/bin/python3' | awk -F '|' '/python3[0-9]*/ {gsub(" ", ""); print \$2}' | awk -F '-' '{print \$1}' | uniq]); | ||
die "There are many python3 versions installed " if (scalar(@system_python_version) > 1); | ||
return $system_python_version[0]; | ||
} | ||
|
||
=head2 get_available_python_versions | ||
returns an array of strings with all the available python versions in the repository | ||
=cut | ||
sub get_available_python_versions() { | ||
my @python3_versions = split(/\n/, script_output(qq[zypper se 'python3[0-9]*' | awk -F '|' '/python3[0-9]/ {gsub(" ", ""); print \$2}' | awk -F '-' '{print \$1}' | uniq])); | ||
record_info("Available versions", "All available new python3 versions are: @python3_versions"); | ||
return @python3_versions; | ||
} | ||
|
||
=head2 get_python3_specific_release | ||
given a python package version, e.g. python311, returns the executable name python3.11 | ||
=cut | ||
sub get_python3_specific_release ($python3_package) { | ||
if ($python3_package eq "python3") { | ||
return script_output("rpm -q python3 | awk -F \'-\' \'{print \$2}\'"); | ||
} | ||
my $sub_version = substr($python3_package, 7); | ||
return "python3.$sub_version"; | ||
} | ||
|
||
=head2 remove_installed_pythons | ||
remove all the installed available python versions | ||
=cut | ||
sub remove_installed_pythons() { | ||
my $default_python = script_output("python3 --version | awk -F ' ' '{print \$2}\'"); | ||
my @python3_versions = split(/\n/, script_output(qq[zypper se -i 'python3[0-9]*' | awk -F '|' '/python3[0-9]/ {gsub(" ", ""); print \$2}' | awk -F '-' '{print \$1}' | uniq])); | ||
record_info("Installed versions", "All Installed new python3 versions are: @python3_versions"); | ||
foreach my $python3_spec_release (@python3_versions) { | ||
my $python_versions = script_output("rpm -q $python3_spec_release | awk -F \'-\' \'{print \$2}\'"); | ||
record_info("Python version", "$python_versions:$default_python"); | ||
next if ($python_versions eq $default_python); | ||
zypper_call("remove $python3_spec_release-base"); | ||
} | ||
} | ||
|
||
1; | ||
|
||
|
||
|
Oops, something went wrong.