Skip to content

Commit

Permalink
Fix testing.register_injectables behavior (#85)
Browse files Browse the repository at this point in the history
* Fixes #81

* Add unit test
  • Loading branch information
Rodrigo Martins de Oliveira authored Mar 20, 2021
1 parent 7c2c4a5 commit 2cee93b
Show file tree
Hide file tree
Showing 55 changed files with 328 additions and 248 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 3.4.5
current_version = 3.4.6

[bumpversion:file:Makefile]
search = CURRENT_VERSION = {current_version}
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Changelog
=========

3.4.6 (2021-03-20)
------------------

* Fix ``testing.register_injectables`` not creating the namespace when it doesn't exist
yet

3.4.5 (2021-03-11)
------------------

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ docs:
make html -B
cp -a build/html/. docs

CURRENT_VERSION = 3.4.5
CURRENT_VERSION = 3.4.6

.PHONY: bump-patch-version
bump-patch-version:
Expand Down
2 changes: 1 addition & 1 deletion docs/.buildinfo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: cd3b2dd68ba32c44728db81e4f0960c3
config: 295a0b1e9f955255820416e4dff32f0b
tags: 645f666f9bcd5a90fca523b33c5a78b7
6 changes: 3 additions & 3 deletions docs/_modules/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Overview: module code &#8212; injectable 3.4.5 documentation</title>
<title>Overview: module code &#8212; injectable 3.4.6 documentation</title>
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../_static/pydoctheme.css" type="text/css" />

Expand All @@ -29,7 +29,7 @@
<h3>Navigation</h3>
<ul>
<li class="responsive-menu"><a href="#sidebar-anchor" title="Navigation">&#9776;</a></li>
<li><a href="../index.html">injectable-3.4.5</a> &#187;</li>
<li><a href="../index.html">injectable-3.4.6</a> &#187;</li>
</ul>
</div>

Expand Down Expand Up @@ -108,7 +108,7 @@ <h3>Navigation</h3>

<div class="footer" role="contentinfo">
&#169; Copyright 2018, Rodrigo Martins de Oliveira.
Last updated on Mar 11, 2021.
Last updated on Mar 20, 2021.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.3.1.
</div>
</body>
Expand Down
6 changes: 3 additions & 3 deletions docs/_modules/injectable/autowiring/autowired_decorator.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>injectable.autowiring.autowired_decorator &#8212; injectable 3.4.5 documentation</title>
<title>injectable.autowiring.autowired_decorator &#8212; injectable 3.4.6 documentation</title>
<link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../../../_static/pydoctheme.css" type="text/css" />

Expand All @@ -29,7 +29,7 @@
<h3>Navigation</h3>
<ul>
<li class="responsive-menu"><a href="#sidebar-anchor" title="Navigation">&#9776;</a></li>
<li><a href="../../../index.html">injectable-3.4.5</a> &#187;</li>
<li><a href="../../../index.html">injectable-3.4.6</a> &#187;</li>
<li><a href="../../index.html" accesskey="U">Module code</a> &#187;</li>
</ul>
</div>
Expand Down Expand Up @@ -175,7 +175,7 @@ <h3>Navigation</h3>

<div class="footer" role="contentinfo">
&#169; Copyright 2018, Rodrigo Martins de Oliveira.
Last updated on Mar 11, 2021.
Last updated on Mar 20, 2021.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.3.1.
</div>
</body>
Expand Down
6 changes: 3 additions & 3 deletions docs/_modules/injectable/autowiring/autowired_type.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>injectable.autowiring.autowired_type &#8212; injectable 3.4.5 documentation</title>
<title>injectable.autowiring.autowired_type &#8212; injectable 3.4.6 documentation</title>
<link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../../../_static/pydoctheme.css" type="text/css" />

Expand All @@ -29,7 +29,7 @@
<h3>Navigation</h3>
<ul>
<li class="responsive-menu"><a href="#sidebar-anchor" title="Navigation">&#9776;</a></li>
<li><a href="../../../index.html">injectable-3.4.5</a> &#187;</li>
<li><a href="../../../index.html">injectable-3.4.6</a> &#187;</li>
<li><a href="../../index.html" accesskey="U">Module code</a> &#187;</li>
</ul>
</div>
Expand Down Expand Up @@ -238,7 +238,7 @@ <h3>Navigation</h3>

<div class="footer" role="contentinfo">
&#169; Copyright 2018, Rodrigo Martins de Oliveira.
Last updated on Mar 11, 2021.
Last updated on Mar 20, 2021.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.3.1.
</div>
</body>
Expand Down
6 changes: 3 additions & 3 deletions docs/_modules/injectable/container/injectable.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>injectable.container.injectable &#8212; injectable 3.4.5 documentation</title>
<title>injectable.container.injectable &#8212; injectable 3.4.6 documentation</title>
<link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../../../_static/pydoctheme.css" type="text/css" />

Expand All @@ -29,7 +29,7 @@
<h3>Navigation</h3>
<ul>
<li class="responsive-menu"><a href="#sidebar-anchor" title="Navigation">&#9776;</a></li>
<li><a href="../../../index.html">injectable-3.4.5</a> &#187;</li>
<li><a href="../../../index.html">injectable-3.4.6</a> &#187;</li>
<li><a href="../../index.html" accesskey="U">Module code</a> &#187;</li>
</ul>
</div>
Expand Down Expand Up @@ -145,7 +145,7 @@ <h3>Navigation</h3>

<div class="footer" role="contentinfo">
&#169; Copyright 2018, Rodrigo Martins de Oliveira.
Last updated on Mar 11, 2021.
Last updated on Mar 20, 2021.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.3.1.
</div>
</body>
Expand Down
15 changes: 9 additions & 6 deletions docs/_modules/injectable/container/injection_container.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>injectable.container.injection_container &#8212; injectable 3.4.5 documentation</title>
<title>injectable.container.injection_container &#8212; injectable 3.4.6 documentation</title>
<link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../../../_static/pydoctheme.css" type="text/css" />

Expand All @@ -29,7 +29,7 @@
<h3>Navigation</h3>
<ul>
<li class="responsive-menu"><a href="#sidebar-anchor" title="Navigation">&#9776;</a></li>
<li><a href="../../../index.html">injectable-3.4.5</a> &#187;</li>
<li><a href="../../../index.html">injectable-3.4.6</a> &#187;</li>
<li><a href="../../index.html" accesskey="U">Module code</a> &#187;</li>
</ul>
</div>
Expand Down Expand Up @@ -94,7 +94,7 @@ <h1>Source code for injectable.container.injection_container</h1><div class="hig
<span class="bp">cls</span><span class="p">,</span>
<span class="n">search_path</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
<span class="o">*</span><span class="p">,</span>
<span class="n">default_namespace</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
<span class="n">default_namespace</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="n">DEFAULT_NAMESPACE</span><span class="p">,</span>
<span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Loads injectables under the search path to the :class:`InjectionContainer`</span>
Expand Down Expand Up @@ -131,8 +131,9 @@ <h1>Source code for injectable.container.injection_container</h1><div class="hig
<span class="ne">DeprecationWarning</span><span class="p">,</span>
<span class="mi">2</span><span class="p">,</span>
<span class="p">)</span>
<span class="bp">cls</span><span class="o">.</span><span class="n">LOADING_DEFAULT_NAMESPACE</span> <span class="o">=</span> <span class="n">default_namespace</span> <span class="ow">or</span> <span class="n">DEFAULT_NAMESPACE</span>
<span class="bp">cls</span><span class="o">.</span><span class="n">NAMESPACES</span><span class="p">[</span><span class="n">default_namespace</span><span class="p">]</span> <span class="o">=</span> <span class="n">Namespace</span><span class="p">()</span>
<span class="bp">cls</span><span class="o">.</span><span class="n">LOADING_DEFAULT_NAMESPACE</span> <span class="o">=</span> <span class="n">default_namespace</span>
<span class="k">if</span> <span class="n">default_namespace</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">cls</span><span class="o">.</span><span class="n">NAMESPACES</span><span class="p">:</span>
<span class="bp">cls</span><span class="o">.</span><span class="n">NAMESPACES</span><span class="p">[</span><span class="n">default_namespace</span><span class="p">]</span> <span class="o">=</span> <span class="n">Namespace</span><span class="p">()</span>
<span class="k">if</span> <span class="n">search_path</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
<span class="n">search_path</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">dirname</span><span class="p">(</span><span class="n">get_caller_filepath</span><span class="p">())</span>
<span class="k">elif</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isabs</span><span class="p">(</span><span class="n">search_path</span><span class="p">):</span>
Expand Down Expand Up @@ -203,6 +204,8 @@ <h1>Source code for injectable.container.injection_container</h1><div class="hig
<span class="p">):</span>
<span class="n">files</span> <span class="o">=</span> <span class="bp">cls</span><span class="o">.</span><span class="n">_collect_python_files</span><span class="p">(</span><span class="n">absolute_search_path</span><span class="p">)</span>
<span class="bp">cls</span><span class="o">.</span><span class="n">LOADING_DEFAULT_NAMESPACE</span> <span class="o">=</span> <span class="n">default_namespace</span>
<span class="k">if</span> <span class="n">default_namespace</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">cls</span><span class="o">.</span><span class="n">NAMESPACES</span><span class="p">:</span>
<span class="bp">cls</span><span class="o">.</span><span class="n">NAMESPACES</span><span class="p">[</span><span class="n">default_namespace</span><span class="p">]</span> <span class="o">=</span> <span class="n">Namespace</span><span class="p">()</span>
<span class="k">for</span> <span class="n">file</span> <span class="ow">in</span> <span class="n">files</span><span class="p">:</span>
<span class="k">if</span> <span class="ow">not</span> <span class="bp">cls</span><span class="o">.</span><span class="n">_contains_injectables</span><span class="p">(</span><span class="n">file</span><span class="p">,</span> <span class="n">encoding</span><span class="p">):</span>
<span class="k">continue</span>
Expand Down Expand Up @@ -282,7 +285,7 @@ <h3>Navigation</h3>

<div class="footer" role="contentinfo">
&#169; Copyright 2018, Rodrigo Martins de Oliveira.
Last updated on Mar 11, 2021.
Last updated on Mar 20, 2021.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.3.1.
</div>
</body>
Expand Down
12 changes: 5 additions & 7 deletions docs/_modules/injectable/container/load_injection_container.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>injectable.container.load_injection_container &#8212; injectable 3.4.5 documentation</title>
<title>injectable.container.load_injection_container &#8212; injectable 3.4.6 documentation</title>
<link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../../../_static/pydoctheme.css" type="text/css" />

Expand All @@ -29,7 +29,7 @@
<h3>Navigation</h3>
<ul>
<li class="responsive-menu"><a href="#sidebar-anchor" title="Navigation">&#9776;</a></li>
<li><a href="../../../index.html">injectable-3.4.5</a> &#187;</li>
<li><a href="../../../index.html">injectable-3.4.6</a> &#187;</li>
<li><a href="../../index.html" accesskey="U">Module code</a> &#187;</li>
</ul>
</div>
Expand Down Expand Up @@ -57,7 +57,7 @@ <h1>Source code for injectable.container.load_injection_container</h1><div class
<div class="viewcode-block" id="load_injection_container"><a class="viewcode-back" href="../../../reference/injectable.html#injectable.load_injection_container">[docs]</a><span class="k">def</span> <span class="nf">load_injection_container</span><span class="p">(</span>
<span class="n">search_path</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
<span class="o">*</span><span class="p">,</span>
<span class="n">default_namespace</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
<span class="n">default_namespace</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="n">DEFAULT_NAMESPACE</span><span class="p">,</span>
<span class="n">encoding</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">&quot;utf-8&quot;</span><span class="p">,</span>
<span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
Expand Down Expand Up @@ -93,9 +93,7 @@ <h1>Source code for injectable.container.load_injection_container</h1><div class
<span class="k">elif</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isabs</span><span class="p">(</span><span class="n">search_path</span><span class="p">):</span>
<span class="n">caller_path</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">dirname</span><span class="p">(</span><span class="n">get_caller_filepath</span><span class="p">())</span>
<span class="n">search_path</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">abspath</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">caller_path</span><span class="p">,</span> <span class="n">search_path</span><span class="p">))</span>
<span class="n">InjectionContainer</span><span class="o">.</span><span class="n">load_dependencies_from</span><span class="p">(</span>
<span class="n">search_path</span><span class="p">,</span> <span class="n">default_namespace</span> <span class="ow">or</span> <span class="n">DEFAULT_NAMESPACE</span><span class="p">,</span> <span class="n">encoding</span>
<span class="p">)</span></div>
<span class="n">InjectionContainer</span><span class="o">.</span><span class="n">load_dependencies_from</span><span class="p">(</span><span class="n">search_path</span><span class="p">,</span> <span class="n">default_namespace</span><span class="p">,</span> <span class="n">encoding</span><span class="p">)</span></div>
</pre></div>

<div class="clearer"></div>
Expand Down Expand Up @@ -145,7 +143,7 @@ <h3>Navigation</h3>

<div class="footer" role="contentinfo">
&#169; Copyright 2018, Rodrigo Martins de Oliveira.
Last updated on Mar 11, 2021.
Last updated on Mar 20, 2021.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.3.1.
</div>
</body>
Expand Down
6 changes: 3 additions & 3 deletions docs/_modules/injectable/errors/autowiring_error.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>injectable.errors.autowiring_error &#8212; injectable 3.4.5 documentation</title>
<title>injectable.errors.autowiring_error &#8212; injectable 3.4.6 documentation</title>
<link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../../../_static/pydoctheme.css" type="text/css" />

Expand All @@ -29,7 +29,7 @@
<h3>Navigation</h3>
<ul>
<li class="responsive-menu"><a href="#sidebar-anchor" title="Navigation">&#9776;</a></li>
<li><a href="../../../index.html">injectable-3.4.5</a> &#187;</li>
<li><a href="../../../index.html">injectable-3.4.6</a> &#187;</li>
<li><a href="../../index.html" accesskey="U">Module code</a> &#187;</li>
</ul>
</div>
Expand Down Expand Up @@ -102,7 +102,7 @@ <h3>Navigation</h3>

<div class="footer" role="contentinfo">
&#169; Copyright 2018, Rodrigo Martins de Oliveira.
Last updated on Mar 11, 2021.
Last updated on Mar 20, 2021.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.3.1.
</div>
</body>
Expand Down
6 changes: 3 additions & 3 deletions docs/_modules/injectable/errors/injection_error.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>injectable.errors.injection_error &#8212; injectable 3.4.5 documentation</title>
<title>injectable.errors.injection_error &#8212; injectable 3.4.6 documentation</title>
<link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../../../_static/pydoctheme.css" type="text/css" />

Expand All @@ -29,7 +29,7 @@
<h3>Navigation</h3>
<ul>
<li class="responsive-menu"><a href="#sidebar-anchor" title="Navigation">&#9776;</a></li>
<li><a href="../../../index.html">injectable-3.4.5</a> &#187;</li>
<li><a href="../../../index.html">injectable-3.4.6</a> &#187;</li>
<li><a href="../../index.html" accesskey="U">Module code</a> &#187;</li>
</ul>
</div>
Expand Down Expand Up @@ -102,7 +102,7 @@ <h3>Navigation</h3>

<div class="footer" role="contentinfo">
&#169; Copyright 2018, Rodrigo Martins de Oliveira.
Last updated on Mar 11, 2021.
Last updated on Mar 20, 2021.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.3.1.
</div>
</body>
Expand Down
6 changes: 3 additions & 3 deletions docs/_modules/injectable/injection/inject.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>injectable.injection.inject &#8212; injectable 3.4.5 documentation</title>
<title>injectable.injection.inject &#8212; injectable 3.4.6 documentation</title>
<link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../../../_static/pydoctheme.css" type="text/css" />

Expand All @@ -29,7 +29,7 @@
<h3>Navigation</h3>
<ul>
<li class="responsive-menu"><a href="#sidebar-anchor" title="Navigation">&#9776;</a></li>
<li><a href="../../../index.html">injectable-3.4.5</a> &#187;</li>
<li><a href="../../../index.html">injectable-3.4.6</a> &#187;</li>
<li><a href="../../index.html" accesskey="U">Module code</a> &#187;</li>
</ul>
</div>
Expand Down Expand Up @@ -273,7 +273,7 @@ <h3>Navigation</h3>

<div class="footer" role="contentinfo">
&#169; Copyright 2018, Rodrigo Martins de Oliveira.
Last updated on Mar 11, 2021.
Last updated on Mar 20, 2021.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.3.1.
</div>
</body>
Expand Down
Loading

0 comments on commit 2cee93b

Please sign in to comment.