<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Amusat Haki Adeyemi</title>
    <description>The latest articles on DEV Community by Amusat Haki Adeyemi (@defidelity).</description>
    <link>https://dev.to/defidelity</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F843519%2Fdbb69e18-5e38-4d12-8700-ebb2315ed087.JPG</url>
      <title>DEV Community: Amusat Haki Adeyemi</title>
      <link>https://dev.to/defidelity</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/defidelity"/>
    <language>en</language>
    <item>
      <title>Protect Your Sensitive Data: A Guide to .env Files in Django</title>
      <dc:creator>Amusat Haki Adeyemi</dc:creator>
      <pubDate>Wed, 22 Feb 2023 19:46:39 +0000</pubDate>
      <link>https://dev.to/defidelity/protect-your-sensitive-data-a-guide-to-env-files-in-django-499e</link>
      <guid>https://dev.to/defidelity/protect-your-sensitive-data-a-guide-to-env-files-in-django-499e</guid>
      <description>&lt;h5&gt;
  
  
  Intro
&lt;/h5&gt;

&lt;p&gt;In the last article where we discussed &lt;a href="https://dev.to/defidelity/production-ready-settings-file-simplest-way-to-get-it-done-509j"&gt;modularization of Django settings file&lt;/a&gt;, a production-ready set-up for Django applications, I mentioned that there would be a short guide on the implementation process of a dot env file in Django.&lt;/p&gt;

&lt;p&gt;In this article, we will be going through that exactly, we will be looking at the implementation process, benefits and why you should consider using a dot env file for all your Django projects.&lt;br&gt;
Let's dive in.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Importance of &lt;code&gt;.env&lt;/code&gt; Files in Django
&lt;/h3&gt;

&lt;p&gt;During the developmental process of a Django application, it's common to have sensitive information such as API keys, Django secret keys, allowed hosts, database passwords, and other credentials that should not be stored in version control systems.&lt;/p&gt;

&lt;p&gt;One way to manage these sensitive values is through the use of environment variables, which can be accessed by your code without being hard-coded into your source files.&lt;/p&gt;

&lt;p&gt;A &lt;code&gt;.env&lt;/code&gt; file is a simple way to manage environment variables in your Django project. It provides a way to store your environment-specific configuration in a file that can be easily managed and shared with other developers on your team, without exposing sensitive information.&lt;br&gt;
There are numerous benefits of using a dot env file in django and some of them are analyzed below.&lt;/p&gt;

&lt;h3&gt;
  
  
  Some of the benefits of using a &lt;code&gt;.env&lt;/code&gt; file in Django
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Security: Sensitive information such as passwords and API keys can be kept separate from your codebase, reducing the risk of exposure to unauthorized access or accidental leaks.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Portability: With a &lt;code&gt;.env&lt;/code&gt; file, you can easily move your application between development, staging, and production environments without having to modify your codebase.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Consistency: By storing your environment-specific configuration in a &lt;code&gt;.env&lt;/code&gt; file, you can ensure that all team members are working with the same settings, reducing the risk of configuration drift.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Also check: &lt;a href="https://dev.to/defidelity/ease-your-way-into-automated-testing-in-django-c88"&gt;Ease your way into automated testing in Django.&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Implementation process of a &lt;code&gt;.env&lt;/code&gt; File in Django
&lt;/h3&gt;

&lt;p&gt;Here's a step-by-step guide on how to implement a .env file in your Django project, follow these steps for a quick implementation:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
Install the &lt;code&gt;python-dotenv&lt;/code&gt; package:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install python-dotenv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Create a file named &lt;code&gt;.env&lt;/code&gt; at the root of your project, the same level as your &lt;code&gt;manage.py&lt;/code&gt;. This file should not be committed to your version control (for example: Github, Gitlab, etc) system.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Add the sensitive information you want to store in your &lt;code&gt;.env&lt;/code&gt; file. Each value should be in the format KEY=VALUE, with one variable per line. For example:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SECRET_KEY=my-secret-key
DEBUG=True
DATABASE_URL=postgres://user:password@localhost/mydatabase
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
In your Django settings file, import dotenv and call load_dotenv(). This will load the variables from your &lt;code&gt;.env&lt;/code&gt; file into your environment variables.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import os
from dotenv import load_dotenv

# Load environment variables from .env file
load_dotenv()

# Access environment variables
SECRET_KEY = os.getenv('SECRET_KEY')
DEBUG = os.getenv('DEBUG')
DATABASE_URL = os.getenv('DATABASE_URL')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With steps as simple as this, you can now use environment variables in your Django project through the &lt;code&gt;.env&lt;/code&gt; file. You can add additional variables to your &lt;code&gt;.env&lt;/code&gt; file as needed and access them in your code through &lt;code&gt;os.getenv()&lt;/code&gt; is shown in the example above. Always make sure &lt;code&gt;os&lt;/code&gt; is imported before referencing it in your project.&lt;/p&gt;

&lt;p&gt;What you want to check now is &lt;a href="https://dev.to/defidelity/production-ready-settings-file-simplest-way-to-get-it-done-509j"&gt;Production ready settings file: The simplest way to get it done.&lt;br&gt;
&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Keep in mind that it's important to keep your &lt;code&gt;.env&lt;/code&gt; file private and not commit it to version control. You may also want to consider using a tool like &lt;code&gt;git-crypt&lt;/code&gt; or &lt;code&gt;git-secret&lt;/code&gt; to encrypt your &lt;code&gt;.env&lt;/code&gt; file to further increase security.&lt;/p&gt;

&lt;p&gt;I hope this gives you a simple overview and great guides to secure your credentials and create a far more secure Django project.&lt;/p&gt;

&lt;p&gt;Thanks for reading, kindly consider sharing to communities where this can be found useful.&lt;/p&gt;

</description>
      <category>seo</category>
      <category>marketing</category>
      <category>ai</category>
      <category>socialmedia</category>
    </item>
    <item>
      <title>Production ready settings file: Simplest way to get it done.</title>
      <dc:creator>Amusat Haki Adeyemi</dc:creator>
      <pubDate>Thu, 19 Jan 2023 11:12:29 +0000</pubDate>
      <link>https://dev.to/defidelity/production-ready-settings-file-simplest-way-to-get-it-done-509j</link>
      <guid>https://dev.to/defidelity/production-ready-settings-file-simplest-way-to-get-it-done-509j</guid>
      <description>&lt;p&gt;All django projects generated from the command line using the &lt;code&gt;django-admin startproject&lt;/code&gt; command comes with a settings file, this file is where all the configuration for your django project is kept including database configuration, static files and even secret keys.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A Django settings file contains all the configuration of your Django installation.  ~ &lt;a href="https://docs.djangoproject.com/en/4.1/topics/settings/" rel="noopener noreferrer"&gt;Django Docs&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Since all the settings are very fragile and most of the variables decleared in the file are meant to be kept private, it's important to modularize the settings file for convenience and ease in both production and local phases of the project.&lt;/p&gt;

&lt;p&gt;Ultimate reason for modularization would be that, most of the variables on the file eg: DEBUG, ALLOWED_HOST, etc. Would have a different value in production compare to the ones declared for them in the local environment, it is there for important to separate the production settings from developmental level settings from start.&lt;/p&gt;

&lt;p&gt;Modularizing a django settings is very simple and pretty straight forward if done with the style introduced in this guide, however, this guide does not include environmental variables set-ups as the plan is to keep the guide simple with just a chunk at a time.&lt;br&gt;
I will be publishing another article in few days that would show a quick guide on environmental variable.&lt;br&gt;
Let's dive in.&lt;/p&gt;
&lt;h3&gt;
  
  
  Modularizing the django settings
&lt;/h3&gt;

&lt;p&gt;The settings needs to be modularized for series of reasons, another of which is to keep our application safe and to reduce the workload of tweaking settings or forgetting to change some variables defined for local machine on production environment, which may prone our django project to series of injections.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Creating a settings folder
The first step to take towards the modularizing concept is to create a settings directory in our main project directory, that is the directory that houses &lt;code&gt;wsgi.py&lt;/code&gt;, &lt;code&gt;asgi.py&lt;/code&gt; and &lt;code&gt;settings.py&lt;/code&gt;, name the new directory: &lt;code&gt;settings&lt;/code&gt;, then don't forget to add the &lt;code&gt;__init__.py&lt;/code&gt; file so python would recognize this directory as a module. 
Move the existing &lt;code&gt;settings.py&lt;/code&gt; file into the new settings directory and the path to settings file should look something like &lt;code&gt;project_name/project_name/settings/settings.py.&lt;/code&gt;
This little change must have breached our project, to assert this run any management command eg &lt;code&gt;manage.py runserver&lt;/code&gt; and you should get a &lt;code&gt;CommandError&lt;/code&gt; stating that the settings file can't be found. 
To rectify this issue, you need to redefine the path to settings in the manage.py file.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You want to check this article on how you can: &lt;a href="https://dev.to/defidelity/protect-your-sensitive-data-a-guide-to-env-files-in-django-499e"&gt;Protect Your Sensitive Data: A Guide to .env Files in Django&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;modifying manage.py to accommodate the tweak
Navigate into the &lt;code&gt;manage.py&lt;/code&gt; file and you should find the generic management template django generated with the &lt;code&gt;django-admin startproject&lt;/code&gt; command, the &lt;code&gt;manage.py&lt;/code&gt; file should look something like this:
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys


def main():
    """Run administrative tasks."""
    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'your_project_name.settings')
    try:
        from django.core.management import execute_from_command_line
    except ImportError as exc:
        raise ImportError(
            "Couldn't import Django. Are you sure it's installed and "
            "available on your PYTHONPATH environment variable? Did you "
            "forget to activate a virtual environment?"
        ) from exc
    execute_from_command_line(sys.argv)


if __name__ == '__main__':
    main()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;You will have to modify the path to settings by changing the path to settings file, so the new path together with &lt;code&gt;manage.py&lt;/code&gt; file would look something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys


def main():
    """Run administrative tasks."""
    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'your_project_name.settings.settings')
    try:
        from django.core.management import execute_from_command_line
    except ImportError as exc:
        raise ImportError(
            "Couldn't import Django. Are you sure it's installed and "
            "available on your PYTHONPATH environment variable? Did you "
            "forget to activate a virtual environment?"
        ) from exc
    execute_from_command_line(sys.argv)


if __name__ == '__main__':
    main()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you run a management command now, it should run as normal.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Modularizing settings for different environments&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You want to start by creating two new files in the settings module/directory, one would be named local_settings.py and the other named production_settings.py for our local and production environments respectively.&lt;/p&gt;

&lt;p&gt;Now you copy everything in the settings file into the two other file by pasting the code below in both of them.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;from .settings import *&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Line &lt;code&gt;import *&lt;/code&gt; would copy everything in the settings file into the two of them meaning we now have two separate settings file for two environments and we have the generic settings file as base.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Configurating management to run the correct setting file based on the environment
The most important concept here is to understand the key difference between the production environment and local environment, the variable &lt;code&gt;DEBUG&lt;/code&gt; in django settings is what allows django to show path to errors, give details about errors and all available paths in a django application and it is meant to be set to &lt;code&gt;True&lt;/code&gt; if you're in local environment so you can easily debug your code and &lt;code&gt;False&lt;/code&gt; in the production environment so django would be able to throw appropriate error when needed and not cast all the secret details about the project.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Knowing this, you'll be using the &lt;code&gt;DEBUG&lt;/code&gt; settings in the management file to configure django so that it would run the correct settings at the correct environmet.&lt;/p&gt;

&lt;p&gt;See this article: &lt;a href="https://dev.to/defidelity/ease-your-way-into-automated-testing-in-django-c88"&gt;Ease your way into automated testing in Django&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The step to this is to import the base settings file and check if DEBUG is true, if it is, django run the local settings and if it's not, django run the production settings. So the code in the management file would look something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
from your_project_name.settings import settings

def main():
    """Run administrative tasks."""
    if settings.DEBUG:
        os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'your_project_name.local_settings')
    else:
        os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'your_project_name.settings.production_settings')

    try:
        from django.core.management import execute_from_command_line
    except ImportError as exc:
        raise ImportError(
            "Couldn't import Django. Are you sure it's installed and "
            "available on your PYTHONPATH environment variable? Did you "
            "forget to activate a virtual environment?"
        ) from exc
    execute_from_command_line(sys.argv)


if __name__ == '__main__':
    main()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is a clever way and you are now assured that django would always run the correct settings based off the environment you're, to affirm that this settings work, go into the base settings file and set the &lt;code&gt;ALLOWED_HOST=['*']&lt;/code&gt;, then tweak the &lt;code&gt;DEBUG&lt;/code&gt; variable from True to False, run the server with &lt;code&gt;manage.py runserver&lt;/code&gt; command and you should see from the log on the command line that django runs the local settings when debug is &lt;code&gt;True&lt;/code&gt; and it runs the production settings when it's &lt;code&gt;False&lt;/code&gt;.&lt;br&gt;
After modularizing the settings, the next big thing to do in order to keep the project safe is to set up environmental variables and keep the special variable values in them, hence the project would be always ready for production.&lt;/p&gt;

&lt;p&gt;In conclusion, I hope you learn something even if it's significantly small, kindly follow me on &lt;a href="https://www.linkedin.com/in/amusat-haki/" rel="noopener noreferrer"&gt;Linkedin&lt;/a&gt; for I share a link to my latest articles on it always.&lt;/p&gt;

&lt;p&gt;Thanks for reading.&lt;/p&gt;

</description>
      <category>gratitude</category>
    </item>
    <item>
      <title>Ease your way into automated testing in Django.</title>
      <dc:creator>Amusat Haki Adeyemi</dc:creator>
      <pubDate>Thu, 12 Jan 2023 13:00:16 +0000</pubDate>
      <link>https://dev.to/defidelity/ease-your-way-into-automated-testing-in-django-c88</link>
      <guid>https://dev.to/defidelity/ease-your-way-into-automated-testing-in-django-c88</guid>
      <description>&lt;h3&gt;
  
  
  Significance of software testing
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;Automated testing is an extremely useful bug-killing tool for the modern web developer. ~ &lt;a href="https://docs.djangoproject.com/en/4.1/topics/testing/"&gt;Django Docs&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Without automated testing, Software developers would neither have a way to affirm the quality of their code, nor would there be a way to assure that the code does the job it's written to do, until it get deployed and becomes available to users that's when they would have to wait for users feedback.&lt;/p&gt;

&lt;p&gt;Writing Tests for any project has become the norm and industrial standard to a point where a programmer can not be taken serious until he writes full functional and unit test for his project and have them go green.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Automated testing is a process that validates if software is functioning appropriately and meeting requirements before it is released into production. This software testing method uses scripted sequences that are executed by testing tools.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Also check this short article on how to: &lt;a href="https://dev.to/defidelity/protect-your-sensitive-data-a-guide-to-env-files-in-django-499e"&gt;Protect Your Sensitive Data: A Guide to .env Files in Django&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Approach to automated testing
&lt;/h3&gt;

&lt;p&gt;This days, there are many approach to testing a software application and the rise in demand of Test first approach amongst programmers is noticeable, you must have heard about "Test Driven Development (TDD)" if at all you belong to any developer community, in which case test is written first before code implementation, and it is written because the programmer wants it to fail, after which he write codes that would make the tests go green (i.e. passed), the code is written to satisfy the test which is basically the desired output.&lt;/p&gt;

&lt;p&gt;The main and most common approach to programming is behavior-driven development (BDD) in which case you develop to satisfy a development plan after which you test to assure quality as opposed to TDD where you develop to satisfy test, then optimize.&lt;/p&gt;

&lt;p&gt;Either way, testing a software project is not a joke and must be taken as an important aspect if not the most important aspect of the project, no matter the level of experience the programmer has.&lt;/p&gt;

&lt;h3&gt;
  
  
  Testing environment
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;Testing a web application is a complex task, because a web application is made of several layers of logic – from HTTP-level request handling, to form validation and processing, to template rendering. ~ &lt;a href="https://docs.djangoproject.com/en/4.1/topics/testing/"&gt;Django Docs&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Proper testing environment set-up is a tedious work because it often require going back and forth between documentations and terminal and having allot of config files to set up so as to assert smooth testing experience once development starts.&lt;/p&gt;

&lt;p&gt;You need to see this article on &lt;a href="https://dev.to/defidelity/production-ready-settings-file-simplest-way-to-get-it-done-509j"&gt;Production ready settings file: Simplest way to get it done&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Testing in Django
&lt;/h3&gt;

&lt;p&gt;Django as a battery included framework ship all app generated through the management command &lt;code&gt;python manage.py startapp&lt;/code&gt; for windows and &lt;code&gt;python3 manage.py startapp&lt;/code&gt; for Mac or Linux with inbuilt test suite configured in a python file named &lt;code&gt;test.py&lt;/code&gt; where the &lt;code&gt;TestCase&lt;/code&gt; a class from the test module has already been imported at the top of the file.&lt;/p&gt;

&lt;p&gt;But the growth of our project would render the test file irrelevant due to the fact that several layer of the app needs require testing and keeping all this in a file wouldn't make any sense, it would rather reduce the readability of the code and end up ruining things when change is required instead of making things better.&lt;/p&gt;

&lt;h3&gt;
  
  
  Steps to set up a proper testing environment in django
&lt;/h3&gt;

&lt;p&gt;In order to have a proper testing environment that requires a one time configuration and would suffix for any project size, we would need to employ some python third party frameworks to help ship our tools faster.&lt;br&gt;
But as project application grows, tests would become more difficult to manage or work with if they’re all saved in a single test file, and also. There are some limitations with Django-inbuilt test suit which can all be handled by python testing library (Pytest).&lt;/p&gt;

&lt;p&gt;In this article, we’ll be learning how to efficiently configure pytest into Django and make them sync with each other and blend well. This would breath ease into your journey of unit testing, Functional testing and System testing.&lt;/p&gt;
&lt;h3&gt;
  
  
  Steps
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Delete the Django follow-come test-file and creation of a tests folder.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This step is pretty straight forward, we want to go into our app folder, the same folder that hosts the Models, Views and Apps file and delete &lt;code&gt;tests.py&lt;/code&gt; file. &lt;br&gt;
After deleting the file, create a new folder and name it &lt;code&gt;tests&lt;/code&gt;, then inside the tests folder, create a new file named &lt;code&gt;__init__.py&lt;/code&gt; this is because without initializing it as a module, python wouldn't recognize it as one.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pytest Installation and Setup&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now, we install our testing library and configure it to work extremely well with our Django project.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Install &lt;code&gt;pytest-django&lt;/code&gt; via pip&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Go to your browser and search for &lt;code&gt;pytest-django&lt;/code&gt; click on the &lt;a href="https://pytest-django.readthedocs.io/en/latest/"&gt;link&lt;/a&gt; that leads to their documentation and copy the pip command to install the package, which is just &lt;code&gt;pip install pytest-django&lt;/code&gt;, paste this command in your terminal or CMD if you're on windows, then click enter to run the command.&lt;/p&gt;

&lt;p&gt;Please note that Pytest is a dependency for &lt;code&gt;pytest-django&lt;/code&gt;, so it would install Pytest and other Pytest's dependencies alongside it, &lt;code&gt;pytest-django&lt;/code&gt; just provides an extremely easy way for us to use the Pytest package in our Django environment.&lt;br&gt;
To be sure that the package is successfully installed, run &lt;code&gt;pytest&lt;/code&gt; in the terminal or CMD and it should return some commands that ends with &lt;code&gt;===========no tests ran in 0.00s===========&lt;/code&gt;, if the case is different for you, then you would need to reinstall the &lt;code&gt;pytest-django&lt;/code&gt; library.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Creation and setup of pytest.ini file.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In the project folder, the same level with &lt;code&gt;manage.py file&lt;/code&gt;, create a new file named &lt;code&gt;pytest.ini&lt;/code&gt;, this is Pytest initiation file that would be run first anytime you run Pytest.&lt;br&gt;
Inside this file we want to initiate Pytest, provide route to our settings module and define the orientation of all tests file, i.e. the type of files pytest should crawl for testing. &lt;br&gt;
Paste this block into your &lt;code&gt;pytest.ini&lt;/code&gt; file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# project_name/pytest.ini
[pytest]
DJANGO_SETTINGS_MODULE = project_name.settings
python_files = test_*.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run &lt;code&gt;pytest&lt;/code&gt; in the terminal or CMD again and it should return the same log as before but with very slight delay in time, which shows that pytest is trying to initiate itself with our &lt;code&gt;.ini&lt;/code&gt; file.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Run an example test.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now, we can go back into our test folder and create an example test to be sure our pytest is well configured.&lt;br&gt;
Inside the &lt;code&gt;tests&lt;/code&gt; directory, create a new file named &lt;code&gt;test_example.py&lt;/code&gt; and paste the dummy code block below in it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# app_name/tests/test_example.py
def test_dummy_example():
    assert 2 == 2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Of course this is expected to return True, but it's called dummy-test because we want to use it to test-run our project and be sure that all is well.&lt;br&gt;
If you run &lt;code&gt;pytest&lt;/code&gt; in the terminal or CMD now, it should return a log that that specify the test folder with the percentage of it's tests that passed and the log should end with &lt;code&gt;============= 1 passed in 0.01s ============&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Also note that if we're to replace the code block by the one below, the test would fail and pytest does a really good job by letting you know where exactly something went wrong so that you may fix it for ease.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# app_name/tests/test_example.py
def test_dummy_example():
    assert 2 == 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the end to this extremely simple guide to testing, I hope this helps and you now understand the reason why you must write tests for your projects even if it's just some dead simple unit test.&lt;br&gt;
Every programmer should get used and comfortable to testing and it's environment and this would give you confidence on the code you wrote.&lt;/p&gt;

&lt;p&gt;Do you also say "Praise be to God" whenever your tests goes green?&lt;/p&gt;

</description>
      <category>django</category>
      <category>testing</category>
      <category>python</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Best way to deliver this content.</title>
      <dc:creator>Amusat Haki Adeyemi</dc:creator>
      <pubDate>Tue, 13 Dec 2022 14:02:02 +0000</pubDate>
      <link>https://dev.to/defidelity/best-way-to-deliver-this-content-36mh</link>
      <guid>https://dev.to/defidelity/best-way-to-deliver-this-content-36mh</guid>
      <description>&lt;p&gt;I'm still looking for the best way to relate the complete journey in such a way that it'll provide value to anyone that hopefully come across it.&lt;/p&gt;

&lt;p&gt;I want it to be in such a way that there'll be zero ambiguity in code explanation, just pure language explained in the best and simplest way while making sure I provide the best solution to each and every one of the question.&lt;br&gt;
Insha Allah, I'll be starting soon.&lt;/p&gt;

</description>
      <category>upwork</category>
      <category>codesignal</category>
    </item>
    <item>
      <title>Series explaining how I'm preparing for my Upwork Academy Skill Assesment exam.</title>
      <dc:creator>Amusat Haki Adeyemi</dc:creator>
      <pubDate>Tue, 06 Dec 2022 21:33:29 +0000</pubDate>
      <link>https://dev.to/defidelity/series-explaining-how-im-preparing-for-my-upwork-academy-skill-assesment-exam-25id</link>
      <guid>https://dev.to/defidelity/series-explaining-how-im-preparing-for-my-upwork-academy-skill-assesment-exam-25id</guid>
      <description>&lt;p&gt;I've chosen to document my way into passing the Upwork skill assessment. I got invite to the assessment some two weeks ago and when I tried getting resources to study ahead of it, I nearly couldn't find one, aside a Reddit user who told me to prepare on Codesignals for the general assessment.&lt;/p&gt;

&lt;p&gt;even after getting this info, there are little to zero deep explanation for the solutions on codesignal question especially for a self thought engineer to understand.&lt;/p&gt;

&lt;p&gt;So, I picked up the challenge to document my way into solving the algorithms and to give clear explanation of how I end up solving each of them, watch this space for the series.&lt;/p&gt;

&lt;p&gt;Kindly wish me luck as I'm still preparing for the exam amidst two heavy projects that I'm working on all alone. Hoping to get trough everything before the end of January.&lt;/p&gt;

</description>
      <category>codesignal</category>
      <category>upwork</category>
      <category>programming</category>
      <category>algorithms</category>
    </item>
  </channel>
</rss>
