Add to Watchlist

The hook-based plugin architecture of py.test


Citation of segment
Embed Code
Purchasing a DVD Cite video

Formal Metadata

Title The hook-based plugin architecture of py.test
Title of Series EuroPython 2015
Part Number 95
Number of Parts 173
Author Bruynooghe, Floris
License CC Attribution - NonCommercial - ShareAlike 3.0 Unported:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal and non-commercial purpose as long as the work is attributed to the author in the manner specified by the author or licensor and the work or content is shared also in adapted form only under the conditions of this license.
DOI 10.5446/20113
Publisher EuroPython
Release Date 2015
Language English
Production Place Bilbao, Euskadi, Spain

Content Metadata

Subject Area Computer Science
Abstract Floris Bruynooghe - The hook-based plugin architecture of py.test The hook-based plugin system used by py.test and being made available as a stand alone package allows easy extensibility based on defined extension points which can be implemented using hook functions in the plugins. Plugins can themselves call these hooks as well as define future extension points allowing for a very flexible design. py.test itself uses this plugin system from the ground up with the entire application being implemented by built-in plugins. This architecture has proven powerful and flexible over the years, on both command line tools as well as long running daemons. This talks will describe how the plugin system works and how it deals with passing arguments and return values 1:N hook calls. It will also describe how to design an application consisting entirely of plugins. While not specifically talking about py.test it will also give a solid understanding on how plugins work in py.test.
Keywords EuroPython Conference
EP 2015
EuroPython 2015
thanks I'm going to 1st and have been a unified that contribute to 4 years now and and and I recently read and write the them so itself it's but it is that it's been using and I'm going to talk a little bit more about that I had a
pretty interesting interactions with the system and so I have itself is is is is just a tool that all of you know when you have use as well it's a yeah it's been around a long time and that is actually the puzzle of against itself it there's over the 50 buttons of the variance and the just the number of with someone else but yeah there's a lot of ligands and they have been around for a long time that and then it's variance simplified so recently it's been split off because it was it's interesting to try and what's nice to be able to use that in all the projects of of and another called some get have actually and the holder crackles username and there was it's so it's a stand-alone version of what has been insisting that so that bit different memory was originally but it's very similar like this is just a couple of details and by the things that we know that I wanna note of caution those fill not voting what really haven't been releasing its 1st conference area expand his mother versions very degraded by point a set the prices says that he will find that that yeah but that shouldn't change too much and little view that's the wall 3 talking this misspelled benefit a simple example and introduce how how things work in this sort of a world that all talk a little bit about what branches of brings and then 2 at the end of the talk about this basically designed your entire application consisting of millions the whole point of this well actually and managing its distance
away from looking at competition so I know you probably all know what a lot logins divergences an why why you want that in applications basically it allows you it's like gives you certain entry points in annual and that point interpretation that regulations allow all the code that you don't know and do attitudes and which collects information the benefits of it and people can extend the things that I never thought of useful basically made and the middle something this evidence and the similarly and of they're not approach to to doing this it's 1 of the functions there's several ways by looking at this and that is basically that you find in Europe Europe extension point as a as a whole that that the application and calls another point you want to extend the vision you call with some arguments and any of the ligands that have been loaded are free to implement the hope and and then they all get hold and so want and Gold collecting and that it just 1 to 1 as well as a in a way I won't really go into much detail about that and it's a book that sort of from is and set of yeah
all of that with this we have a very simple and the people of writing this 1st and this is basically it's just the application i'm going to use to demonstrate to this very simple you just gets gets euro and assignment time using the costs of a little bit of fun here breaking out so that this is basically rest will get the right spread out like a this sort of slightly lower level and that's because it will allow me to extend extend the application of this spectacle doesn't do very much and I'm going to basically the 1st extension point and integrate is basically out against the modified had is that I sent in requests so in this case that means that after after the
request has called and the object has had this feature headers and I'm going to allow it to be Institute for 1 the choice before actually starting to request do
ask a bloody event from each and you define your your your points you're extension points it took specifications and generally I don't want to we used to test the spectral to turn the right so it's a simple model that and all you need to do is basically you have to break and is not good for application 1st so that the expected and that again is that correct the what but the greatest and you just name all that you really care about all that but you really can't have it is a signature that you defined as that is actually important so the name of the name of the book and the argument states that are important in the history of the interaction of structuring about it when I was and the is the sum of the and thing itself began by convention the prefix was like your application and something that is not strictly necessary find that and nothing is like this actually negative that is purely at the signature of the functions in G so having defined specification and letters get ahead and write and you look at
what the implementation is and that's right really very straightforward so this is just 1 example in finest and I'm using the example and and generally again for doing the write implementation of food was also in the beginning to the unit is that correct to decorate your implementation was so that they can run low duplicate is instantiated variable and and find you you remember that your own actions using the great Jan generally the application exposes that so just as an API to to in writing so putting the application itself while in the and the rest of the information released so the argument is just make dictionary have and I modified but do you notice that the the implementation of it only only uses this the 1 and
that has argument to the go back to the to the fishery vegetative another session
of argument as well there but but it doesn't foresee that been very basis allow us to coach the only the data except the articles that need and what you will look at the signature of of of Europe implementation and from that will figure out which we which and and that is that's kind of a good feature when you're right when you go to often and any you're extending them so because that you
see easier backwards compatibility that's the that's what you need to Due to change application and the still found similar on discovering more imports the 1st thing we introduce new here that the local market and integrate that decorated that was used to having it that we just said and and then actually the the main application is that the vertical lines there are concerned about creating the splitting energy so the greatest living matter again name and then and it's important so I going the specification that I don't trust then this is it's just model object and in this case so you you register all the books and using that greater in in especially when you will asked at Stanford hopes and a fundamental change in this case I'm using just simple important to you look look look dynamically load might begin and 1 and then you just need to register with them during the rest of the following is is best it's and so it's like the earlier request of certain traits such rare and then actually going to observe a golden manager object and within amount of the has this whole contribute which is program and after after after you've management specifications for for each group that you have to find the Lagrange call in there which allows you to call you and that is the way you actually going out from from implications and in in this case the thing to notice also is that when you call and so you have to provide me all the time and you don't know what the which are integrated using and have to specify specified in and object give them as keyword arguments as well because but the at the names of the arguments did you know which which arguments that you have documentation that so they need to be frostiness if you forgets argument or get it wrong fortunate because it is required from the slide so you don't get terribly useful elements at the moment and you know you can improve and that's what it is that have just so that is all that is essentially at all you know
you need you to choose great Britain started the yeah what 1 more thing
basically because of the various I didn't actually return and value so you you can have multiple ligands all implementing this and they're all have had the same dictionary and they would all have had the tree of and Boston them and that all the more times in the chair that when you don't want to return of that's also possible and metadata and a list of and the release of all returned values the child and then the patient has to decide
what's going to as a as a quick example for this and I'm going to add another specification this 1 is sort of not much but I mean that's not all the best example I can read and write English but but but it's really the the border this at the of space and they return true or false William recommended by the fact is that you should make use of rests within an hour or something so good sketched starts with the central with the game itself within as well and really straightforward to implement don't really care the want those random so yes edges with 100 a very important factor and even after the accident a lot of things in In this international motivation
good skid as well so and this is
actually the application so get getting at is not not much has changed with selecting until the that's what is being called the the patterns the goal exact same columns after the best the I just and this is exactly the same so basically got called of golden university returns a list and I use built-in all all that in all of the functions to the invite you to just go and see if any in any of those like that's the largest and then just did send the response is the an rest of the brain
responsible and so so that's so that you wouldn't so but was also you know the actual introduction to how to write and there's a lot more features actually essentially the application finds a certain that point the there and the thing about standards function signatures so the function signature the implementation the and are extensively on the Institute unit used and you get you have basically what was the 1 calling Application lots of calls in England it's going to turn by this is the bunch of law the last features that are really going to and just like that and points that of image points integration so you don't have to write all from scratch if you want to use set the tools that and you can also influence the ordering of that so so sometimes that might matter so you might want to be run within like there is being run early or late sometimes and grabbing something similar to that you play in actually gets called before all the other groups can call and then you get gets the result as well so it gets encoded the beginning and the end of of all the other planets in and doing that gives you access to the because you begin to actually see the result that the other applicants have produced and you can even quantifiable returns the house to constant and that additive if you want to and the last 1 interesting feature that use established the buttons that are right implements for you but if you want to look at billions can actually the features possibly imagine object to you that is not something from from the internet Latin you specifications to imagine which that can be called from there are more 7 it's yet
slightly unique way way of of right within the in the bottom of that you haven't started classes in and the French disease as being strict and it allows you to as I I said it loudly more flexibility so because doesn't force you can me justify function beginning amend modulus adjust it implementing you but it hasn't class well and and the feature vector with you good communication doesn't have fewer crops or doesn't have the all the arguments is also allows you to evolve lot and easier because you can change it have adding new arguments and all kinds of people and that seems to have a pile of just really the other thing is that the data is that because that there's no there's no class writing involved in the forward and behavioral workflow and state that you have to keep arrangements and if you if you want to be accepted by standard states we can implement others as possible that you can teach David but also leads to if you have a very simple billion a very simple this force on you that next ultimately how you can how you you can actually use that is to design an
obligation within this is better system with the mother so basically but as it is so like creating setting up you imagine that rights that is very small so all you need to have is a very small bootstrap and module that will it can also some called built in the gate and that those the and 2 bonds foreign and applications and they can have responsible actually do it but most of the birds so they can density can just use a couple of hundred against and then there's begins with others on looking at some of the people the world is using names the use of and whatever kind of mechanism you like to use the it's this sort of approach has been used and artist has been pioneering ups and it's hard enough and and that's sort for command line tools sure also use it for longer as well so it kind of its itself of different types of applications and the interesting part of the you know your entire data exists out of fuel but as using but in advance of the
beginning of kind of shows that you make within makes for a very flexible and extensible conditions as well so if that's the only modify my my little for application to to start to to do do that is this the Internet like so inhibits the emigration to make main functions are taking of the kind of more costly for the modeling this case and in this case all all it's doing is it's same pregnant with but as you can see actually and create a list of corporate against and have just implemented this called again How can we cannot do this that begins so I just think important already and in the end when registering OK my call into 1 and then register and and what ones that can call call is you know the then new hope that are specified in the in the and that's the end of the application like that that there should be only be 1 again we that implements and although all the Institute implemented to override it but it's only slightly more advanced than just use that value it actually cation solar so like
showing actual so so this is the 2 blood inherits the so-called called applying disparity in implementing this sort of workflow so this is actually now that the 1 that drives this girl named notice this 1 that triumphed in the rest of the application you'll notice that 1 of the more it is strictly necessary so this sort of when when when writing and application to and and of the inside as as well as think about it is still to be useful to you know like a great operating plug-in manager migrated confirmation objects and then later on I pray that the session objectives nice it's nice abstraction and actually work quite well so gender generally I make the configuration object made responsible for doing things like passing command line concrete files try and that kind of provides some obligations states which is essentially the static configuration the result of and then In this section of the regret session using earlier the quality and the session the that such an object is this that allows you to kind of keep run-times stated about your application to if you have any inside of the nice patterns and once once you once you going to and you can see like I call that looks like configure and session starting to finish and conveyed on lexicon uses this example this question the it is it's not pattern and allows for you but instead of you know on the exponents and you exercise to configurational maybe androgens that operation and things gave and that's left after that sort of done so so need to see I've actually and move the argument passenger comfort objectives passing object and and they have the evidence indicates the rest of the cortex in generic title search and the methods and just like 1 agrees that more but it's going to get more so so it is 1 that will make the rest good responsible for executing the
core and so and so because can scientists still the same model and so just during basically the the complete objects some of the level of intelligence still no damages Boston MA and but yet it's the greater the efficiency of our system on and it seems like a reasonable idea was that the 1st session in there if my application features where there was a progressive multiple neural so something that picture is a section of the page to the section for for that and so all that there's a decent chance that and then actually still so your order and you look at greater was designed this made requests and information access in this very similar to what we saw before so just yeah its exactly exams courses the only difference here is basically the now do you understand him from the complete objects and they section is now and the end of the session is from the generalisation object
that's going to be on differences of wanting like but I think this nice example and In this way of writing so the handing of cooperation in and in in in a bit the and it basically the key in the evening the evening like criteria argmin past during my what's helped you can have led Logantan interacted and it's nice because you can and in this case on this amendment in a plug-in specially responsible for making this request and the your arguments on the command line I'm actually making the concerns of the plug-in actually wants to use this so you can so it's a nice way of right of separated concerns and there is no need to have 1 central parliament passed something that needs to know what you want to do and this is of yet again pretty straightforward to implement so landing here is like this something of that that already had and that's and was already responsible for closing down the lines and I'm actually going it properly this time around and bring about about a possible and the Due to the small training basically did you get your arguments about possibly against just divide and other than to before we will utilize the arguments about last as the answer to all the gradients that that want and the arguments here just in the same again directly implemented as well having my your and and yet at the outset that the the the the the the arrests changes a little bit about again not really interested in just because of the Ural is now in this slide different occasional Michael the videos constant that have very straightforward very similar and this is sort of yeah
this and this is the way that so this way of but also by using this so that as well this is a very simplified so would look at the hopes that part that defines and how how it them but it's it's interesting to to it doesn't cover a of tools and also is is very good and what really here and but you can see sports impacts and so it starts with creating its own version of but imagine that anyway and then it breaks this this conflict check and that helps in the Gospel of alliances the nasty things and go guidance that option which I have had had the option than block online parsing is implemented as well and then it basically stopped forms of the and system online 1 and I hope that Istanbul that prior to the rest of the application can you see and in that the same pattern is also known as the great recession and then you get all obligations the chance to kind of working who came to this configuration and sessions setups so low and the widest data marked inspection start finish and on the European as well and that's so main and in the name of the 5 test this stands hospitable is due to make steps which like collection of all the test and then running all tests and then inside those that it is again also work to even more and more and there is more to the population as well
so it's so but it shows that you know of if you think about how you structure you don't have to try to so the way of thinking about the final pitch and it works quite
nicely in some situations
and so to get some of the yes so and it's a it's an information system it allows you to fulfill your plugin API quite nicely and it's very and it has very little more on on the right keep simple things simple the but likewise here if you do need to store state also thing you can do this well that just might affect that actually alone right you all applications of again there's no obligation at all to do it like the 1st example and I start from a study establishing is very low overhead like on images great within manager so it's actually not that the hard you have a if you have an existing application that you want to go for this system there's no need to to go you know this whole effort to meet be the consignment still very gentle traditional kind of adding a few there's no much and but it is likely find interesting right if you start from scratch that might be interesting to consider this kind of funny waiting to try and align their patients it works quite well in practice questions and so there was while like what we want to say about and the question the I thank you for the great talk about so far as which very interesting and but when I think about it so usually I would plead with the option
1 object of also another and that way extends the the the the functionality and this is much more dynamic in way and it gives the the the thing that you can read the plug them in and the discovered topic but that was the missing their power all do you know configure your application to get from plantations is that is that no intended in this design or not that that the user input what when the user has the application and he can have a variable set of proteins right it and so how is that considered hardest excavated active in locations as the configure yes that's kind of where I was and amazingly referring to you have set of tools integration or something so it kind of leaves its value to the application of the typical things out of use them into that and to points of 1 this is you if you go and what about that any distribution this private and if you have any distribution is the that represent point and that they'll be registered and it's up to application can and you know decide otherwise you can yeah that's a modified as if that's the you didn't give you enough control the commandments which is to use compression file so is kind of leads up to the application selects which buttons are you usually you have a set of core obligations kind of and provide basic functionality and present new functionality in interests of Gaussians by from which discourse of photos of single dispatch so generating function mechanism can be quite useful for some types of foreign functionality when you want to but from some so is way to integrate that we thank you for this practice that you just use them side by side and so so think about genetics single this response is not 1 of to them I haven't really used much myself so that's where you it is decides to a great looks at the top of the 1st argument and then decide how we understand the conditional of I'm not sure how to answer the questions that I haven't really thought about it how that interact interacts at the end of the the bloody but it doesn't really do anything like that that you are in you just get your arguments in the implementation so you you you you're information is wrong if this 5 karen and just return on then the inference engine I say if you have multiple plug-ins it's up to the application to take the results of it you have to call from each different plugging and then somehow integrate them the so can you tell the reader that have to like so that then something that the application often leads to think about as suppose I to different plug-ins want to for example modify the hidden and also like it because it into passing dictionaries your books then the kind of thing that really matters right because they could be modified in place and so yeah yeah as so old order relevant data that can be relevant sometimes and society and that's where but he has some so it's the when you're implementing the Europe can say that the decorator and so if I didn't go into this with accurate states you can you can basically call like function and I'm giving the documents as so then and I can make the you can influence your e-mail that students in our hearts be called you know that at the beginning I want to be called at the end and so obviously modifying yeah when you define objects you don't you don't have a stretch of border ordering guaranteed rather the wrapping methods and uses was another 1 especially migrate you will be called the beginning and at the end of and the other part of question what you like as if you application author you need to eat into about how what kind of a hundred people might run against the the right where if if multiple buttons on the value that list was them and yeah the application domain that there's also uh what 1 of the things you can do on on the engaged listening and I referred you to do 1 1 and called well and based in the specification you you can say something like it if if this different and values this is not very useful for like this last activities the challenge in when I showing that there the inside of the actually referendum main functions so if multiple that implement made it would be kind of some something funny with happening system and the day so the the way to solve that is why we use this specifying you say I wonder if I wanna create a 1 to 1 1 call rate which you might not in the 1st result I think you would his 1st results on the left and then and then that is if you look at that point you can you can plug in ordering going as well so that point if you you begin go on actually I I wanna be called before the normal main main 1 for example and so on and and then basically look at you know to to do I want to very can decide to I want to return a value and actually become a or do I just don't not and if I don't know and then the next quote will get chances to be made so yeah that's of the and thanks just another 1 about some return values is there any way too much or its own values come from which 1 and strictly speaking not really unless you happen to know the order of of ligands so it would exactly so uh take a few tightly control the also when when manager was going to register with an object that that will there is actually was respect so if you if you know it's a video that things are not registered in in there and if you know all duplicons implement look this was the only resentment will have a return value and then you can sort of get no dropping numbers all you you can Is there anything to consider when can apply sources if you want to test a in anything especially if he's lost his job I not really because they're on the way to decorate this work on on on you makes it quite nice because actually affecting the function at all it just marks in which is not functioning which make it and functional geneticists it so we need to just go and call it directly and actually going interesting easier in some way the question is what is the same outside and the it able blood blood and you can essentially so you you got in your you again imagine duration the also unregistered high there but so that any point you can you can iteratively conceived of all the genes being registered in within just of as if you can think of a trader with graphical model and I want to be in the they have a little concern In the benefits this like to mention that the basically past and the argument you want but that that's more or less the behavioral with expect from just quick from Python because this could be to some loss of so you can't box any of you on at
at the set so when you a and that the the
reason to this page In the
specification that when you actually and those are the arguments that you have them actually implemented and you can't call it anything else if you if you don't and the only thing that
can be used a and the next slide implementation and you can leave out 1 and that that is basically just implemented as a signature inspection so it is it's maybe a little bit on conventional unconventional inviting this is what I have to determine provides all the random inspection and uh it's if you if you use to by the test image features will seem very natural to you as well yeah it's OK that's a little bit older 1st but it's not really doesn't really violent terrible things yeah doesn't allow you to spot in an existing things I'd still like to them you so that's what the recording and for the audience the 1 thing is some thinking about because plug-ins is normally the should shouldn't be part of your application and normally and buttons you have wonderful on applications start to do something going on on obligations use something else and if if everything is plugged in volume and what application is something because there is like an obligation of this is everything is flexible you know what I mean because if you can not disabled plugging it's not of living so there have been problem in the sense that the blame approach right assists yeah I mean could complete reputation cation if you really wanted but that's you know decoding right and you know and you can screw up everything anyway if you really want to I get out of here yeah but the continent gentlemen or something like that so it's we the yeah In fact I think it's not really an issue of no yeah you as it's it's been for a long time and by accident yeah you could say you could complete will replace the mainland and go and something else but the end of the at the end of the day help anyone entering tedious right now we're at the a time of the
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation


  402 ms - page object


AV-Portal 3.8.0 (dec2fe8b0ce2e718d55d6f23ab68f0b2424a1f3f)