Image of an arrow

Press Review Inno #8

Avatar

admin_sflinux

Special Edition on PyConCa 2017

This week, we attended PyCon Canada which started on November 18 and lasted through 21. We are also proud and happy that we played a role in sponsoring this dynamic event. In this Special Edition of Press Review Inno, you find articles from our SFLers who actively participated in the event’s sessions.

PyCon 2017

Our Team Who Attended PyConCa 2017

 

Tutorial: Writing Tests that Write Themselves by David Kua

Summarized by Ernesto Rodriguez Ortiz

Stop worrying about corner cases and start loving the power property-based testing.

I just discovered the concept of property-based testing at PyCon Canada 2017, thanks to David Kua who prepared, showed and shared with us a great tutorial of property-based testing using the library Hypothesis. (Welcome to Hypothesis!)

In fact, the concept of property-based testing was popularized by the Haskell library Quickcheck. I am happy about my new discovery because I find myself too often thinking about corner cases in my tests, and now I don’t need to spend as much time considering this, as they will show up themselves with the help of Hypothesis.

So How Does This Work?

Hypothesis generates random data matching your specification and checks that your guarantee still holds up for each test case. Check out this really simple example:

# FILE NAME division.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
 
# You wrote these two lines way too fast...
def division(x, y):
    return x / y
 
# Hypothesis will now show you your mistakes...
from hypothesis import given, settings
import hypothesis.strategies as st
 
@given(st.integers(), st.integers())
@settings(max_examples=1000)
def test_commutativity_pbt(x, y):
    assert division(x, y) * y == x

Then run:

pytest --hypothesis-show-statistics division.py

You should see how Hypothesis has found the corner case:

ZeroDivisionError: division by zero

This is powerful stuff, so go play a little with the awesome tutorial prepared by David Kua and check the documentation of Hypothesis.

Closing Keynote – Mariatta Wijaya

Summarized by Sébastien Blin

During the closing keynote, Mariatta Wijaya, a Python Core Developer, presented us Python 3.6 through the lens of a PEP (Python Enhancement Proposal) that has been released in this version: PEP 498: Literal String Interpolation.

Mariatta explained the history of this PEP, from its beginnings as a Python mailing list post since a few years ago. The new feature introduced in this PEP, colloquially called “f-strings”, allows for an improved experience in creating strings with variables in them, all the while improving performance and making for a more codebase than when the % operator or str.format functions are used.

>>> import datetime
>>> name = 'Fred'
>>> age = 50
>>> anniversary = datetime.date(1991, 10, 12)
>>> f'My name is {name}, my age next year is {age+1}, my anniversary is {anniversary:%A, %B %d, %Y}.'
'My name is Fred, my age next year is 51, my anniversary is Saturday, October 12, 1991.'
>>> f’He said his name is {name!r}.'
"He said his name is 'Fred'."

She then gave a brief overview of the other PEPs released with Python 3.6 (including PEP 628 which adds math.tau, which did not exist prior, and the value of which is 6.28). The complete list of PEPs in Python 3.6 is available at Python 3.6 Release Schedule.

In any case, Mariatta invites us to upgrade to Python 3.6 as soon as possible, as well as to contribute to the evolution of the programming language through the creation of new PEPs at this GitHub repo.

Contributions

GitHub Releases a Team-Based Discussion Feature

By Romain Bertozzi

To contribute to open source software means to share with others, so it only follows that the ability to effectively communicate is critical. GitHub announced a new feature on the 20th of November centered around team-based discussions.

The idea of this feature is to create a space for conversations within a project that might not be best placed under issues or pull requests. These issues and PRs will now be freed up and will be less of a magnet for long, irrelevant comment threads. In addition to this, these new discussions, public or private, will have dedicated URLs and will be able to be easily shared and cited on other sites.

Here at Savoir-faire Linux, we welcome this news enthusiastically. We believe that it will bring more clarity around the discussions related to the creation, management and direction of a project. The centralization and the ease-of-use of these discussions are benefits that will allow for more transparency and longevity of conversations. It remains to be seen how this functionality will be adopted by GitHub users, who already have many different options available to them that they may be more used to.

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.


Similar articles

Image of an arrow

Savoir-faire Linux participated in the tenth edition of DrupalCamp Montréal, which was held this year at Concordia University. It was the occasion to catch up with a good proportion of the Drupal developer community in Montreal, to exchange ideas with other companies that work with this technology, and to have an overview of how Drupal […]

Avatar
26 Jun. 2018 Reading from 2 minutes.

When It Comes to Websites, Page Speed Matters! This article is motivated by our website project accomplished by our Integration Platforms and AI Department using Liferay 7 (the latest version of Liferay Portal) for one of our clients– a large Canadian corporation in telecommunications and media industry. Alexis, our front-end developer, shares with you his first-hand experience […]

Avatar
12 Mar. 2018 Reading from 6 minutes.
Thumbnail image

Web Development Getting Started with Server-Side Rendering in Angular By Kévin Barralon This week we released a tutorial for developers using the Angular JavaScript framework to set them up with a pre-configured server-side rendering environment. This environment allows for the pre-rendering of an Angular site so that its contents can be made visible to robots […]

Avatar
13 Dec. 2017 Reading from 3 minutes.
Thumbnail image

Server-Side Rendering Management: An Angular’s Novelty Imposing a Challenge Angular is a framework using the TypeScript Programming Language. Its 5th version (pentagonal-donut) was released in November 2017, containing new features and bugfixes. It is accompanied by the command line tool Angular CLI and new features such as a server-side rendering framework that has become very popular within the community of Angular […]

Avatar
11 Dec. 2017 Reading from 7 minutes.
Thumbnail image

Design What Is Design System? By Patrick Bracquart For several years now, the complexity of the websites and applications has pushed us towards rethinking the concept of design, as well as the methodologies we use in the design process. This rethink is pushed by an ever-expanding field of necessary skills and positions in design such […]

Avatar
7 Dec. 2017 Reading from 2 minutes.
Close
Close