recentpopularlog in

kme : testing   213

« earlier  
Same steps for multiple named environments with GitLab CI - Stack Overflow
Yes, you can use anchors ( If I follow the documentation properly, you would rewrite it using a hidden key .XX and then apply it with <<: *X.

For example this to define the key:
<code class="language-yaml">.job_template: &deploy_definition
- deploy ${CI_ENVIRONMENT_SLUG}</code>

And then all blocks can be writen using <<: *job_template. I assume environment will merge the name with the predefined URL.
<code class="language-yaml">
<<: *deploy_definition
name: test

<<: *deploy_definition
name: stage

<<: *deploy_definition
name: prod</code>
testing  gitlab  gitlab-ci  yaml  anchors  syntax  reference 
7 weeks ago by kme
cgi.parse Python Example
The key is those environment variables. I always forget that part.

<code class="language-python">def do_test(buf, method):
env = {}
if method == "GET":
fp = None
env['QUERY_STRING'] = buf
elif method == "POST":
fp = BytesIO(buf.encode('latin-1')) # FieldStorage expects bytes
env['CONTENT_TYPE'] = 'application/x-www-form-urlencoded'
env['CONTENT_LENGTH'] = str(len(buf))
raise ValueError("unknown method: %s" % method)
return cgi.parse(fp, env, strict_parsing=1)
except Exception as err:
return ComparableException(err)</code>
dammitbrain  webdevel  python  cgi  testing  solution 
8 weeks ago by kme
A Quick Puzzle to Test Your Problem Solving - The New York Times
As you seem to have guessed, the answer was extremely basic. The rule was simply: Each number must be larger than the one before it. 5, 10, 20 satisfies the rule, as does 1, 2, 3 and -17, 14.6, 845. Children in kindergarten can understand this rule.

But most people start off with the incorrect assumption that if we’re asking them to solve a problem, it must be a somewhat tricky problem. They come up with a theory for what the answer is, like: Each number is double the previous number. And then they make a classic psychological mistake.

They don’t want to hear the answer “no.” In fact, it may not occur to them to ask a question that may yield a no.

Remarkably, 77 percent of people who have played this game so far have guessed the answer without first hearing a single no. A mere 9 percent heard at least three nos — even though there is no penalty or cost for being told no, save the small disappointment that every human being feels when hearing “no.”

It’s a lot more pleasant to hear “yes.” That, in a nutshell, is why so many people struggle with this problem.

One of the best-selling business books in history — about negotiation strategy — is “Getting to Yes.” But the more important advice for us may instead be to go out of our way to get to no. When you want to test a theory, don’t just look for examples that prove it. When you’re considering a plan, think in detail about how it might go wrong.
confirmationbias  psychology  testing  no 
november 2019 by kme
python - How can I simulate input to stdin for pyunit? - Stack Overflow
As of Python 3.5 "If you are patching builtins in a module then you don’t need to pass create=True, it will be added by default."

<code class="language-python">
@patch.object(module_under_test, "raw_input", create=True)
def test_using_decorator(self, raw_input):
raw_input.return_value = input_data = "123"
expected = int(input_data)

actual = module_under_test.function()

self.assertEqual(expected, actual)</code>
python  mock  monkeypatching  testing  unittest  solution 
october 2019 by kme
benibela/xidel: A command line tool to download and extract data from HTML/XML pages or JSON-APIs, using CSS, XPath 3.0, XQuery 3.0, JSONiq or pattern templates. It can also create new or transformed XML/HTML/JSON documents.
This tool seems to be able to deal with malformed HTML that 'xmllint' and 'xmlstarlet' choke on (even after a pass through 'tidy').
A command line tool to download and extract data from HTML/XML pages or JSON-APIs, using CSS, XPath 3.0, XQuery 3.0, JSONiq or pattern templates. It can also create new or transformed XML/HTML/JSON documents. - benibela/xidel
xml  html  webscraping  webdevel  api  testing  alternativeto  xmllint  xmlstarlet 
may 2019 by kme
bats-core/bats-core: Bash Automated Testing System |
Bash Automated Testing System. Contribute to bats-core/bats-core development by creating an account on GitHub.
shellscripting  bash  testing  framework  unittesting  automation  devel  alternative  to  ts  bats 
january 2019 by kme
Running Selenium with Headless Chrome |
<code class="language-python">from selenium import webdriver

options = webdriver.ChromeOptions()
chrome  webdevel  selenium  automation  testing  webdriver  python  solution 
october 2018 by kme
How can I send POST and GET data to a Perl CGI script via the command line? - Stack Overflow |
Add 'CGI qw( -debug )'.

<code class="language-perl">#! /usr/bin/perl
use warnings;
use strict;

use CGI qw/ :standard -debug /;

print "Content-type: text/plain\n\n",
map { $_ . " => " . param($_) . "\n" }

Also interesting:
To give a cgi script post data:
<code class="language-bash">$ echo -n 'a=b;c=d' | REQUEST_METHOD=POST CONTENT_LENGTH=999 perl index.cgi</code>

To give a cgi script get data:
<code class="language-bash">
$ perl index.cgi 'a=b;c=d'</code>

Of *course* that's how CGI works, but it's easy to forget that's how it works.
perl  testing  debugging  commandline  solution  webdevel  cgi  dammitbrain 
august 2018 by kme
dd - How do I create a 1GB random file in Linux? - Super User
@PeanutsMonkey: Right; you would need something like dd if=/dev/urandom bs=750M count=1 | uuencode my_sample > sample.txt. – Scott Sep 6 '12 at 19:33
webmaster  sysadmin  testing  random  data  generator  shellscript  bash  shell  solution 
january 2017 by kme
« earlier      
per page:    204080120160

Copy this bookmark:

to read