summaryrefslogtreecommitdiff
path: root/HACKING.rst
Commit message (Collapse)AuthorAgeFilesLines
* mock.assert_called_once() is not a valid methodDavanum Srinivas2014-09-161-0/+1
| | | | | | | | | | | | | | mock.assert_called_once() is a no-op that tests nothing. Instead with mock.assert_called_once_with() should be used (or use assertEqual(1, mock_obj.call_count) if you don't want to check parameters). Add a new HACKING rule for nova to prevent assert_called_once() usage from creeping in. Closes-Bug: #1365751 Change-Id: I1055093a1c31792b6411a3cd46c80b8bcaaf78c1
* Merge "Move to oslo.db"Jenkins2014-09-071-1/+1
|\
| * Move to oslo.dbAndrey Kurilin2014-09-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Replace common oslo code nova.openstack.common.db by usage of oslo.db library and remove common code. Replaced catching of raw sqlalchemy exceptions by catches of oslo.db exceptions(such as DBError, DBDuplicateEntry, etc). Co-Authored-By: Eugeniya Kudryashova <ekudryashova@mirantis.com> Closes-Bug: #1364986 Closes-Bug: #1353131 Closes-Bug: #1283987 Closes-Bug: #1274523 Change-Id: I0649539e071b2318ec85ed5d70259c949408e64b
* | Remove concatenation with translated messagesJames Carey2014-08-271-0/+1
|/ | | | | | | | | | | | | | | | | Translated messages should not be expanded by concatenation. Instead the additional text should be replacement text or part of the translated message to allow the translators as much information as possible when doing the translations. Also, when lazy translation is enabled, the object returned does not support concatenation and raises an exception. Thus this patch is needed to support blueprint: i18n-enablement. This patch includes a hacking check for concatenation with a translated message. Change-Id: I8b368d275faa14b4750735445321874ce1da37d5 Partially-Implements: blueprint i18n-enablement
* Remove use of str on exceptionsJames Carey2014-08-271-0/+1
| | | | | | | | | | | | | | | | | | | | | | An exception's message can be a translatable message. If it is, the message can contain unicode characters which will cause str to fail. In cases where the message is explicity needed, the use of str is replaced with the use of six.text_type. When an exception is used as a replacement string in a format string, the logger correctly handles it without the need for str, so it is removed. In addition to the case where a translatable message contains unicode, enabling lazy translation in the oslo.i18n library causes translatable messages to be replaced with an object that does not support str, this causes all calls to str on a translatable message to fail. Thus this patch is also needed to support blueprint: i18n-enablement. This patch includes a hacking check for use of str() on exceptions identified in except statements. Change-Id: Idb426d7f710ea69b835f70d0e883e93e9b9111d2 Partially-Implements: blueprint i18n-enablement
* Hacking: a new hacking check was added that used an existing numberGary Kotton2014-08-141-0/+1
| | | | | | | | | | Commit 243879f5c51fc45f03491bcb78765945ddf76be8 added in a new hacking check that used an existing number. The new number is 324 (and not 323) Change-Id: I7e604a408387438105c435ad16a1fa3d6491b642 Closes-bug: #1356815
* Add hacking check for explicit import of _()Jay S. Bryant2014-08-031-0/+1
| | | | | | | | | | | | | | To ensure the right message catalog is used when translating messages we need to make sure to explicitly import '_' in any files that use that function. We cannot count on unit test to catch cases where the user has forgotten to import the _() function. This hacking check ensures that the function has been imported anywhere that it is used. Unit tests for the hacking check are included. Change-Id: I9d8101916bcb449345d3123617c2ac75776d053e
* Removes the use of mutables as default argsChangBo Guo(gcb)2014-06-181-0/+1
| | | | | | | | | | | Passing mutable objects as default args is a known Python pitfall. We'd better avoid this. This commit changes mutable default args with None, then use 'arg = arg or {}', 'arg = arg or []'. For unit code which doesn't use the args , just set with None. This commit also adds hacking check. Closes-Bug: #1327473 Change-Id: I5a8492bf8ffef8e000b13b6bdfaef1968b96f816
* Add missing translation supportGary Kotton2014-06-021-0/+1
| | | | | | | | | | | | | | | Update a number of files to add missing translation support. The patch adds a new hacking check - N321. This ensures that all log messages, except debug ones, have translations. A '# noqa' indicates that the validation will not be done on the specific log message. This should be used in cases where the translations do not need to be done, for example, the log message is logging raw data. Closes-bug: #1290261 Change-Id: Ib2ca0bfaaf432e15448c96619682c2cfd073fbbc
* Update HACKING.rst to include N320Gary Kotton2014-06-021-0/+2
| | | | | | | | Commit 9235ada8c2c250603dc5b299cc08bb7a982d4fc6 did not add in the updated hacking rule. Change-Id: If2daf6d2e7008c36d0aba6270ac034522dcb2e2b Closes-bug: #1325812
* Add a reference to the nova developer documentationMichael H Wilson2014-05-191-0/+4
| | | | | | | | I've showed these docs to more people than I care to. It would be extremely helpful to reference them in HACKING, which is generally the first thing people read if they intend to hack. Change-Id: I9194d98f5525e29711b4a1b26414a50b8ceba525
* Hacking: add rule number to HACKING.rstGary Kotton2014-04-271-0/+1
| | | | | | | | Commit ac8bce63f8a7ec8a2ebb214ea7f86ee4f8adecae added hacking rules N319. This was not documented in the file HACKING.rst. Change-Id: Ibf7917aaada88db5afe1387859a387481ec05118 Closes-bug: #1313322
* Replace assertEqual(None, *) with assertIsNone in testszhang-jinnan2014-02-161-0/+2
| | | | | | | Replace assertEqual(None, *) with assertIsNone in tests to have more clear messages in case of failure. Change-Id: I0d38a82e78fbe94657ab9a71c08422007843d179
* Change assertTrue(isinstance()) by optimal assertMarcos Lobo2014-02-121-0/+4
| | | | | | | | | Some of tests use different method of assertTrue(isinstance(A, B)) or assertEqual(type(A), B). The correct way is to use assertIsInstance(A, B) provided by testtools. Change-Id: I4a5413f9d90d2e581044885a440a46bf3d76598f Closes-Bug: #1268480
* Remove @author from copyright statements.Michael Still2014-02-121-0/+2
| | | | | | | | | We have git to track authorship, so let's not pad source files with it as well. Co-authored-by: Joe Gordon <joe.gordon0@gmail.com> Change-Id: Ic2d62d6743f7716c086749cd99922b6c496771d4
* Renumber some nova hacking checksDaniel P. Berrange2014-02-101-1/+3
| | | | | | | | | | | Most of the nova hacking checks had picked numbers starting from approx N300 onwards. Two recent additions randomly picked N123 and N500. Renumber these to N313 and N314 and make sure they're documented in HACKING.rst. Mention the guidelines in the hacking source file for benefit of future authors Change-Id: Ia3eb4cb9a4ac7409db7eba9e1689f4a5780b8795
* Add hacking test to block cross-virt driver code usageDaniel P. Berrange2014-02-041-0/+6
| | | | | | | | | | | | | | | | The baremetal driver has been accessing some libvirt driver private classes and config variables. Any code that is intended to be shared across virt drivers should be in a common package instead. Add a hacking file to enforce this for imports and config options so that no further problems like this are made in the future. NB, this skips verification of the baremetal driver until bugs 1261826 and 1261827 are fixed, or the baremetal driver is removed, whichever comes first. Change-Id: Ifbfe597795795a847830f9bd937dc459cd37d118 Closes-Bug: #1261842
* Remove vi modelinesliu-sheng2014-02-031-0/+1
| | | | | | | | | | We don't need to have the vi modelines in each source file, it can be set in a user's vimrc if required. Also a check is added to hacking to detect if they are re-added. Change-Id: I347307a5145b2760c69085b6ca850d6a9137ffc6 Closes-Bug: #1229324
* Updates OpenStack Style Commandments linkKeshava Bharadwaj2013-10-161-1/+1
| | | | | | | The current link in the HACKING file is broken. This references the correct location for contributors to view. Change-Id: I3cd4841035400d09a3e3e3369bb3a2a8c4bdee30
* Use timeutils.utcnow() throughout the codeRoman Podolyaka2013-07-191-0/+2
| | | | | | | | | | | | timeutils.utcnow() should be used instead of direct calls to datetime.datetime.utcnow() to make it easy to override its return value in tests. Add a hacking rule to prevent regressions. Fixes bug 1200141. Change-Id: I170dbd7c9093bd627e2a0d5984b7ad1bf105c8d5
* Add HACKING check for db session paramDevananda van der Veen2013-07-021-1/+2
| | | | | | | | | | Add a HACKING check to enforce that public db/api and db/sqlalchemy/api methods to not accept a 'session' parameter. This check is initially disabled, since it is failing ~24 times right now, but will be enabled once bp/db-session-cleanup is complete. Change-Id: Ib89eea58555032dd142d4e21e62d66e2726f0d06
* Clean up and make HACKING.rst DRYerJoe Gordon2013-07-011-290/+16
| | | | | | | Reference the OpenStack hacking guide in HACKING.rst and remove duplicated entries. Add new section for nova specific rules. Change-Id: I704a49a0675acf1870953c76eba4978a1c4490eb
* Merge "Add notes about how doc generation works."Jenkins2013-06-131-0/+21
|\
| * Add notes about how doc generation works.Monty Taylor2013-06-021-0/+21
| | | | | | | | Change-Id: I562c743798aeae5e49bd2f96944c3cacd776a53d
* | Replace openstack-common with oslo in HACKING.rstThomas Bechtold2013-06-071-6/+6
| | | | | | | | Change-Id: I8c6426983ec374e903c64108b990e5d4550e3fcc
* | Improve Python 3.x compatibilityDirk Mueller2013-06-011-0/+19
|/ | | | | | | | | Mechanical translation of the deprecated except x,y: construct with except x as y: The latter works with any Python >= 2.6. Add Hacking check. Change-Id: I845829d97d379c1cd9b3a77e7e5786586f263b64
* docs should indicate proper git commit limitSteven Dake2013-03-041-2/+2
| | | | | | | | | | | The nova gate should recommend 50 characters or less for a git commit but actually enforce 72 characters. This patch changes the hacking.rst docs to indicate the actual limit is 72 characters rather then 50 characters. Change-Id: I47f1f1f1007f5744bf1fef419df7e033803b4a53 Fixes: Bug #1144840
* Fix broken logging imports.Vishvananda Ishaya2013-02-191-1/+0
| | | | | | | | This fixes all of the files incorrectly importing logging directly and removes the workaround in hacking.py that was due to improper from nova.openstack.common.log import logging statements. Change-Id: Icfc25dc148c4a7b5fa7f6a7b609cd6c3d94efee1
* Module import style checking changesAttila Fazekas2013-02-131-0/+3
| | | | | | | | | | | | | | * Implementing the * import detection (it is disabled for now) * New style relative import testing based on syntax rules * Old style relative import testing based on module search * Inspection based solution replaced by PYTHONPATH search in order to avoid module compile and initialization steps (code execution) in a syntax checking phase. This solution is faster and safer, but does not able to recognize modules added dynamically to the module scope. Change-Id: Ifc871f4fdbcd4a9a736170ceb4475f4f2cbe66bc
* Update docs about testing.Monty Taylor2013-02-111-1/+21
| | | | | | | | Add an entry to the HACKING file about testr. While in there, noticed a reference to the now-defunct nova/testing dir. Fixed that, moved the testing README into nova/tests and remove the nova/testing dir. Change-Id: Ibf6fb82658ba73eee9123fa53b340d0b72afb292
* Update HACKING.rst per recent changesZhongyue Luo2013-02-041-3/+10
| | | | | | | | | | | | Added "is not" usage with examples * https://review.openstack.org/#/c/20865/ Fixed "not in" usage description * https://review.openstack.org/#/c/20875/ Fixed some "not X in Y" corner cases. Change-Id: I7534ef73e6fd525fd8f4bee594a4b37524699c08
* Fixes 'not in' operator usageZhongyue Luo2013-01-311-0/+12
| | | | Change-Id: I1e26a8fcb9fa564308e63c11a72aaa55119e4eee
* don't allow crs in the codeSean Dague2013-01-161-0/+1
| | | | | | | | triggered by this slipping into quantum, now that we have more windows developers we should ensure that \r\n doesn't land in the code as a line ending. This check prevents it. Change-Id: I0a82be0e74915d3c3c25203db110d279580c148b
* Changed 'OpenStack, LLC' message to 'OpenStack Foundation'Kurt Taylor2013-01-071-1/+1
| | | | Change-Id: Iffad63690d2d7565c651ff3faec4443d0ed471c3
* Ban db import from nova/virtDan Smith2012-11-121-0/+1
| | | | | | | | | | | | | | This makes hacking.py complain if someone adds something like: from nova import db into any of the files in nova/virt/* (aside from the fake.py file). It also removes the rest of the dangling db imports that are no longer needed. Yay! Change-Id: Iba3d53b87e65e33a55f8e5033b5d1d33b28d12f7
* hacking: Add driver prefix recommendation.Rick Harris2012-08-291-0/+4
| | | | | | | | | Prefixing the commit message's first line with the driver makes it easier for reviewers, at a glance, to find reviews that relate to their area of expertise as well as improving the overall readability of the git history. Change-Id: I376d2cdb5dc344717fb7749a80e33ee88603e68c
* OpenStack capitalization added to HACKING.rstJoe Gordon2012-08-171-0/+9
| | | | | | Along with capitalization fixes to comments in code Change-Id: I72ddc582001f80d954ca5a121903c689f40d08d1
* Add a 50 char git title limit test to hacking.Joe Gordon2012-08-081-1/+2
| | | | | | * add N802 to hacking.py Change-Id: I8262531b4b3f8f3a1a2a37679904cf4864cae7b6
* Add a link from HACKING to wiki GitCommitMessages pageDaniel P. Berrange2012-07-301-0/+6
| | | | | | | | | | | | | | The HACKING file contains a short example of an effective commit message. For reasons for space, it cannot describe the rationale behind this example. It also does not have space to describe how to split up a patch into a series of commits. Add a link from the HACKING file to the wiki http://wiki.openstack.org/GitCommitMessages where further information can be found Change-Id: I34d44485486b623b11743106f09d5ef631d35888
* Expand HACKING with commit message guidelinesBrian Waldon2012-07-021-0/+21
| | | | | | | Add a 'Commit Messages' section to HACKING describing how a commit message should be formed. Change-Id: I29b69022dfbdac09523eaa5cef3fc1a4550a7c5f
* Backslash continuation removal (Nova folsom-2)Zhongyue Luo2012-05-311-0/+2
| | | | | | | | Fixes bug #938588 Backslash continuations removal for scripts in bin/, plugin/, and etc. Change-Id: Idd17048b6e8db6e939946968e011e68da8585b8d
* Improved tools/hacking.pyJoe Gordon2012-04-241-1/+1
| | | | | | | | | | | | | * cleaner output * fix bug 980009 * Fix N201 * N306: alphabetical order imports * N401: docstring start * N402: one line docstring start * N403: multi line docstring end * Until fixed, N40* will be disabled by default Change-Id: I9addafdaa7a1f8fb950e14a5409f661dec6c7b87
* HACKING fixes, sqlalchemy fix.Yuriy Taraday2012-04-091-2/+8
| | | | | | | Add exceptions to hacking.py make sqlalchemy stuff legal and prevent clutter. Change-Id: I44b100b4c0c4dfcec81beea7aba2d8598d5a08d0
* Reordered the alphabet.Andrew Bogott2012-03-231-1/+1
| | | | | | | | | | | | | | | Just putting this out there... I'm pretty sure that import nova.flags comes after from nova.endpoint import cloud Unless I'm totally misunderstanding how this is supposed to work, which is likely. Change-Id: I51096ab25dbca42d73a593872b83b25f2c451210
* Clarify HACKING's shadow built-in guidance.Rick Harris2012-03-211-1/+12
| | | | Change-Id: Icf38d3ec3254e83d2289b7b17966ec44d9757b8c
* Clear created attributes when tearing down testsJohannes Erdfelt2012-03-071-12/+0
| | | | | | | | | | | | | | | | unittest will keep each test case around after completion pinning any objects references by attributes on the test case. This can bloat the memory used during a full test suite run to the point where the test suite will require much more memory than running all of the services does. On systems witout lots of memory, test suite failures will occur as test cases cannot fork to execute programs. Clearing out __dict__ of any attributes that don't start with a _ (since some are needed by unittest itself) reduces memory significantly. This does require the super class tearDown to be called last in some cases however. Change-Id: I0e660b6c2a77c5613c5a523ba0a64c3d7f6dd128
* assertRaises(Exception, ...) considered harmfulJohannes Erdfelt2012-03-041-0/+12
| | | | | | | | | | | | | | | Expecting that Exception is raised can end up passing an a test when an unexpected error occurs. For instance, errors in the unit test itself can be masked: https://review.openstack.org/4848 https://review.openstack.org/4873 https://review.openstack.org/4874 Change a variety of unit tests to expect a more specific exception so we don't run into false positive tests in the future. Change-Id: Ibc0c63b1f6b5574a3ce93d9f02c9d1ff5ac4a8b0
* Update cfg from openstack-commonMark McLoughlin2012-02-071-0/+15
| | | | | | | | | | | | | | Use openstack-common's update.py script to pull in some recent changes: * Add the Mapping interface to cfg.ConfigOpts * Add support to cfg for disabling interspersed args Make use of both of these in nova/flags.py. Add some dire warnings to HACKING about directly modifying the copy of openstack-common code. I'm confident they won't be ignored :-) Change-Id: I7ef75d18922c0bbb8844453b48cad0418034bc11
* Update HACKING.rst.Kevin L. Mitchell2012-01-051-4/+1
| | | | | | | | | Removes the requirement for a trailing blank line in multiline docstrings, just before the closing '"""'. This blank line is not needed anymore, as the editors it was recommended for no longer have the problem that this blank line was working around. Change-Id: I4e532231f1d99e9f5048cbfcc791a4328fb1e8f5
* First steps towards consolidating testing infrastructureDuncan McGreggor2011-12-061-0/+184
This commit begins to implement blueprint consolidate-testing-infrastructure by adding a 'testing' subpackage and moving some modules into it. Change-Id: I04bf860bc386bd2016e7dbc5a6f6ef7379a855bb